private void CargaContacto(string campoCondicion, TextBox textBox) { string campoValor = textBox.Text.Replace("'", "\\'").Trim(); DataTableContacto = ConsultasSql.Busqueda(tabla: "contact", condicion: campoCondicion, valor: campoValor, campo: "id, id_number, business_name, address, landline", campoOrden: "business_name"); if (campoValor.Length > 0 && DataTableContacto.Rows.Count > 0) { ContactoDataGridView.DataSource = DataTableContacto; ContactoDataGridView.Size = new Size(350, 120); ContactoDataGridView.Location = new Point(textBox.Location.X + 10, textBox.Location.Y + 26); ContactoDataGridView.ColumnHeadersVisible = false; ContactoDataGridView.RowHeadersVisible = false; ContactoDataGridView.AllowUserToAddRows = false; ContactoDataGridView.AllowUserToDeleteRows = false; ContactoDataGridView.BackgroundColor = Color.White; ContactoDataGridView.AllowUserToResizeColumns = false; ContactoDataGridView.AllowUserToResizeRows = false; ContactoDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ContactoDataGridView.ReadOnly = true; Controls.Add(ContactoDataGridView); ContactoDataGridView.BringToFront(); ContactoDataGridView.Visible = true; ContactoDataGridView.Columns["id_number"].Width = 90; ContactoDataGridView.Columns["business_name"].Width = 256; ContactoDataGridView.Columns["id"].Visible = false; ContactoDataGridView.Columns["address"].Visible = false; ContactoDataGridView.Columns["landline"].Visible = false; } else { ContactoDataGridView.Visible = false; } }
private void AsignarCeldasDataGridViewAVariables() { ContactoDataGridView.Focus(); IdContact = ContactoDataGridView.CurrentRow.Cells["id"].Value.ToString(); IdNumberContact = ContactoDataGridView.CurrentRow.Cells["id_number"].Value.ToString(); BusinessNameContact = ContactoDataGridView.CurrentRow.Cells["business_name"].Value.ToString(); AddressContact = ContactoDataGridView.CurrentRow.Cells["address"].Value.ToString(); LandlineContact = ContactoDataGridView.CurrentRow.Cells["landline"].Value.ToString(); }
private void EventoKeyDownContactoIdOrName(KeyEventArgs e, TextBox textBox) { if (e.KeyCode == Keys.Down) { if (ContactoDataGridView.Rows.Count > 0) { ContactoDataGridView.Focus(); } } if (e.KeyCode == Keys.Escape) { if (ContactoDataGridView.Rows.Count > 0) { ContactoDataGridView.Visible = false; } textBox.Focus(); } }