Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/07/2010, 21:27
evikar
 
Fecha de Ingreso: julio-2010
Mensajes: 19
Antigüedad: 14 años, 7 meses
Puntos: 0
[c#]Ejecutar al Completar caracteres

me explico amgos

necesito simular un commandbutton al completar sierta cantidad de caracteres

Código:
        private void txtnumshipper_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')  //<-- aqui ejecuto al precionar la tecla enter o intro.. pero necesito que se ejecute al completar 8 caracteres ej: s0263335
            {
                SqlConnection cn = new SqlConnection();
                cn.ConnectionString = "Data Source=xxxxxxxxxx;Initial Catalog=xxxxxxxx;User ID=xxxx";
                SqlCommand cm = new SqlCommand("Select custid,billname from soshipheader where shipperid='" + txtnumshipper.Text + "' ", cn);
                SqlDataAdapter ad = new SqlDataAdapter(cm);
                DataSet da = new DataSet();
                ad.Fill(da, "soshipheader");
                try
                {
                    cn.Open();
                    label1.Visible = true;
                    label2.Visible = true;
                    label1.DataBindings.Add("Text", da, "soshipheader.custid");
                    label2.DataBindings.Add("Text", da, "soshipheader.billname");

                }
                catch (Exception c)
                {
                    MessageBox.Show(c.Message);
                }
                finally
                {

                    if (cn.State == ConnectionState.Open)
                    {
                        cn.Close();
                    }
                }

            }

        }

if (e.KeyChar == '\r') //<-- aqui ejecuto al precionar la tecla enter o intro.. pero necesito que se ejecute al completar 8 caracteres ej: s0263335