C sharp - Evento Keypress

 
Vista:

Evento Keypress

Publicado por Diego (3 intervenciones) el 26/11/2013 19:14:20
Hola a todos

Tengo un problema con c# .Net 2003 en Formularios para windows .

Tengo los textbox programados con el Keypress si el usuario presiona enter se va al siguente textbox esto funciona correctamente hasta que el usuario presiona un boton, ahi si el usuario va a los textbox y quiere salir con enter se ejecuta el evento del boton en vez del evento del textbox.

Agradezco su ayuda con este tema

Saludos Cordiales

Diego
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Francisco Javier

Evento Keypress

Publicado por Francisco Javier (7 intervenciones) el 27/11/2013 15:57:12
Hola Diego,
Podrías proporcionarme tu código de los evento por favor, así podría ayudarte mucho mejor.
Gracias (=
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Evento Keypress

Publicado por Diego (3 intervenciones) el 27/11/2013 18:23:10
Que tal Francisco gracias por tu ayuda este es el codigo de uno de los botones abre la pantalla de articulos o productos de acuerdo al id de la tabla articulo muestra la informacion del articulo seleccionado en el grid esto funciona correctamente pero al salir de la pantalla del articulo y presionar enter se ejecuta otra vez el codsigo del boton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
bool bExiste = true;
try
{
    if (ultraGrid1.ActiveRow.Cells["idArticulo"].Value == null || ultraGrid1.ActiveRow.Cells["idArticulo"].Value == DBNull.Value)
        bExiste = false;
}
catch
{
    bExiste = false;
}
 
if (ultraGrid1.ActiveRow.Cells["idArticulo"].Value == null || ultraGrid1.ActiveRow.Cells["idArticulo"].Value == DBNull.Value) return;
 
int idTG = Funcion.iEscalarSQL(cdsSeteoF, string.Format("Select ISNULL(idTipoGrupo, 0) From Articulo Where idArticulo = {0}", (int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value));
 
if (idTG != 1 && idTG != 6)
{
    frmArticulosServicios miArticuloServicios;
 
    miArticuloServicios = new frmArticulosServicios((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value);
    miArticuloServicios.ShowDialog();
    miArticuloServicios.Dispose();
}
else
{
    Articulo miArticulo;
    if (bExiste)
        if (Funcion.bEjecutaSQL(cdsSeteoF, "Exec SeteoGExiste 'ARTMPREC'"))
        {
            miArticulo = new Articulo((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value,
                (double) ultraGrid1.ActiveRow.Cells["Precio"].Value);
        }
        else
            miArticulo = new Articulo((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value);
    else
        miArticulo = new Articulo();
 
    miArticulo.ShowDialog();
    miArticulo.Dispose();
    miArticulo = null;
 
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Francisco Javier

Evento Keypress

Publicado por Francisco Javier (3 intervenciones) el 27/11/2013 23:38:43
Hola Diego, disculpa por la tardanza de respuesta, estoy en mi trabajo.
puedes proporcionarme por favor también el código del evento "KeyPress"

por favor, pega acá desde donde empiezan los eventos, es decir, desde el nombre del control, por ejemplo:

public text_Box_KeyPress(...) //DESDE ESTA PARTE
{
...
}

así puedo identificar que código pertenece a qué control.

Gracias (=
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Evento Keypress

Publicado por Diego (3 intervenciones) el 28/11/2013 00:01:12
Al contrario gracias por tu gentil ayuda

aqui te envio del boton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
private void btBuscaArticulo_Click(object sender, System.EventArgs e)
{
    bool bExiste = true;
    try
    {
        if (ultraGrid1.ActiveRow.Cells["idArticulo"].Value == null || ultraGrid1.ActiveRow.Cells["idArticulo"].Value == DBNull.Value)
            bExiste = false;
    }
    catch
    {
        bExiste = false;
    }
 
    if (ultraGrid1.ActiveRow.Cells["idArticulo"].Value == null || ultraGrid1.ActiveRow.Cells["idArticulo"].Value == DBNull.Value) return;
 
    int idTG = Funcion.iEscalarSQL(cdsSeteoF, string.Format("Select ISNULL(idTipoGrupo, 0) From Articulo Where idArticulo = {0}", (int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value));
 
    if (idTG != 1 && idTG != 6)
    {
        frmArticulosServicios miArticuloServicios;
 
        miArticuloServicios = new frmArticulosServicios((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value);
        miArticuloServicios.ShowDialog();
        miArticuloServicios.Dispose();
    }
    else
    {
        Articulo miArticulo;
        if (bExiste)
            if (Funcion.bEjecutaSQL(cdsSeteoF, "Exec SeteoGExiste 'ARTMPREC'"))
            {
                miArticulo = new Articulo((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value,
                    (double) ultraGrid1.ActiveRow.Cells["Precio"].Value);
            }
            else
                miArticulo = new Articulo((int) ultraGrid1.ActiveRow.Cells["idArticulo"].Value);
        else
            miArticulo = new Articulo();
 
//las siguientes 4 lineas les puse recien por probar pero no resulto
        miArticulo.ShowDialog();
        miArticulo.Dispose();
        miArticulo = null;
        this.btBuscaArticulo.AcceptsFocus = false;
 
 
    }
}

y aqui esta el de uno de los textbox

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if (e.KeyChar == 13)
{
    if (IdTipoFactura == 4)
    {
        int idCliente = 0;
        if (drCompra["idCliente"] != System.DBNull.Value) idCliente = (int)drCompra["idCliente"];
        int iGC = 0;
        if (idCliente > 0) iGC = Funcion.iEscalarSQL(cdsSeteoF, string.Format("Select IsNull(idGrupoCliente, 0) From Cliente Where Proveedor = 1 And idCliente = {0}", idCliente));
        if (iGC != 2 && iGC != 3)
        {
            char Pad = '0';
            drCompra["Numero"] = this.txtNumero.Value.ToString().PadLeft(9, Pad);
        }
    }
    this.txtRuc.Select();
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar