cerrar un formulario

24/06/2005 - 09:06 por Anonimo | Informe spam
Hola a todos !!!! tengo un problema y es que llamo a un formulario desde
otro con el codigo siguiente

if (this.camOF==null)
{
this.camOF=new CambioOF();
this.camOF.Identificador=this.Identificador;
}
.
..
if (camOF.ShowDialog()==DialogResult.OK)

DESPUES DENTRO DE ESE FORMULARIO EN EL LOAD TENGO UN POSICIONAMIENTO A UN
CONTROL DTERMINADO CON EL FOCUS()

this.OFSelec.Focus();

SIN EMBARLO LA PRIMERA VEZ QUE LO HAGO LO HACE BIEN, PERO DESPUES DE CERRAR
EL FORMULARIO SI VUELVO A ENTRAR ME POSICIONA EL FOCO EN EL ULTIMO CONTROL
QUE LO TENIA Y ESO QUE SE VE QUE PASA POR EL this.OFSelec.Focus()

TIENE ESTO SOLUCION PARA QUE SE POSICIONE SIEMPRE EN EL CONTROL QUE YO LE
MANDO ???

SALUDOS Y GRACIAS

Preguntas similare

Leer las respuestas

#1 Miguel Angel Campos
24/06/2005 - 10:15 | Informe spam
Prueba con this.ActiveControl = this.OFSelec.
Según la MSDN para que se pueda establecer en foco en un control mediante
Focus se deben dar una serie de situaciones, pues alguna de ellas no se da
durante el evento Load del formulario, pero no se exactamente cual.

Un Saludo,

Miguel Angel Campos
MCAD.NET

escribió en el mensaje
news:
Hola a todos !!!! tengo un problema y es que llamo a un formulario desde
otro con el codigo siguiente

if (this.camOF==null)
{
this.camOF=new CambioOF();
this.camOF.Identificador=this.Identificador;
}
.
..
if (camOF.ShowDialog()==DialogResult.OK)

DESPUES DENTRO DE ESE FORMULARIO EN EL LOAD TENGO UN POSICIONAMIENTO A UN
CONTROL DTERMINADO CON EL FOCUS()

this.OFSelec.Focus();

SIN EMBARLO LA PRIMERA VEZ QUE LO HAGO LO HACE BIEN, PERO DESPUES DE
CERRAR
EL FORMULARIO SI VUELVO A ENTRAR ME POSICIONA EL FOCO EN EL ULTIMO CONTROL
QUE LO TENIA Y ESO QUE SE VE QUE PASA POR EL this.OFSelec.Focus()

TIENE ESTO SOLUCION PARA QUE SE POSICIONE SIEMPRE EN EL CONTROL QUE YO LE
MANDO ???

SALUDOS Y GRACIAS


Respuesta Responder a este mensaje
#2 Pedro Luna Montalvo, [MVP VB.NET]
24/06/2005 - 15:17 | Informe spam
Otra alternativa es que le des el foco al control justo antes de invocar el
dialogo (ShowDialog()).


Saludos,
Pedro Luna, [MVP VB.NET]
Gye, Ecu

escribió en el mensaje
news:
Hola a todos !!!! tengo un problema y es que llamo a un formulario desde
otro con el codigo siguiente

if (this.camOF==null)
{
this.camOF=new CambioOF();
this.camOF.Identificador=this.Identificador;
}
.
..
if (camOF.ShowDialog()==DialogResult.OK)

DESPUES DENTRO DE ESE FORMULARIO EN EL LOAD TENGO UN POSICIONAMIENTO A UN
CONTROL DTERMINADO CON EL FOCUS()

this.OFSelec.Focus();

SIN EMBARLO LA PRIMERA VEZ QUE LO HAGO LO HACE BIEN, PERO DESPUES DE
CERRAR
EL FORMULARIO SI VUELVO A ENTRAR ME POSICIONA EL FOCO EN EL ULTIMO CONTROL
QUE LO TENIA Y ESO QUE SE VE QUE PASA POR EL this.OFSelec.Focus()

TIENE ESTO SOLUCION PARA QUE SE POSICIONE SIEMPRE EN EL CONTROL QUE YO LE
MANDO ???

SALUDOS Y GRACIAS


Respuesta Responder a este mensaje
#3 Tristan
25/06/2005 - 00:47 | Informe spam
Ten en cuenta que para que un control pueda recibir el foco, tiene que ser
visible. En el evento Load, a menos que hagas un Show previamente el
formulario no es visible.

Para arreglarlo siemplemente llama a Show en el Load, antes de invocar
Focus().

Juan Carlos Badiola
MVP - C#
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida