private void Buscar_TextChanged(object sender, EventArgs e) { try { DataView dv = new DataView(dt.Copy()); try { dv.RowFilter = CMB_Buscar.Text + " Like '%" + Buscar.Text + "%'"; } catch (Exception) { if (Buscar.Text != "") { try { if (Convert.ToInt32(Buscar.Text) >= 0) { dv.RowFilter = CMB_Buscar.Text + " = " + Buscar.Text; } } catch (Exception) { MessageBox.Show("Favor escribir un valor correcto", "Texto incorrecto"); Buscar.Text = ""; Buscar.Focus(); } } } Datos.DataSource = dv; if (dv.Count == 0) { noencontrado.Visible = true; } else { noencontrado.Visible = false; } } catch (Exception) { MessageBox.Show("Favor escribir un valor correcto", "Texto incorrecto"); Buscar.Text = ""; Buscar.Focus(); } }
private void CMB_Buscar_SelectedIndexChanged(object sender, EventArgs e) { Buscar_TextChanged(null, null); Buscar.Focus(); }