private void CargaProducto(DataGridView dataGridView) { ProductoPanel.Size = new Size(400, 160); ProductoPanel.Location = new Point( dataGridView.GetCellDisplayRectangle(0, dataGridView.CurrentRow.Index, false).Location.X + mainPanel.Location.X + 2, dataGridView.GetCellDisplayRectangle(0, dataGridView.CurrentRow.Index, false).Location.Y + mainPanel.Location.Y + dataGridView.GetCellDisplayRectangle(0, dataGridView.CurrentRow.Index, false).Size.Height + 2); ProductoPanel.BackColor = Color.WhiteSmoke; BusquedaProductoTextBox.Location = new Point(5, 5); BusquedaProductoTextBox.Width = 390; BusquedaProductoTextBox.CharacterCasing = CharacterCasing.Upper; ProductoDataGridView.Size = new Size(390, 120); ProductoDataGridView.Location = new Point(5, 30); ProductoDataGridView.ColumnHeadersVisible = false; ProductoDataGridView.RowHeadersVisible = false; ProductoDataGridView.AllowUserToAddRows = false; ProductoDataGridView.AllowUserToDeleteRows = false; ProductoDataGridView.BackgroundColor = Color.White; ProductoDataGridView.AllowUserToResizeColumns = false; ProductoDataGridView.AllowUserToResizeRows = false; ProductoDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ProductoDataGridView.ReadOnly = true; Controls.Add(ProductoPanel); ProductoPanel.Controls.Add(BusquedaProductoTextBox); ProductoPanel.Controls.Add(ProductoDataGridView); ProductoPanel.BringToFront(); FiltrarProducto(); if (dataGridView.CurrentRow.Cells[1].Selected || dataGridView.CurrentRow.Cells[0].Selected) { ProductoPanel.Visible = true; BusquedaProductoTextBox.Focus(); BusquedaProductoTextBox.SelectAll(); } else { ProductoPanel.Visible = false; } }
private void ProductoDataGridView_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if (ProductoDataGridView.CurrentCell.RowIndex == 0) { BusquedaProductoTextBox.Focus(); } } if (e.KeyCode == Keys.Enter) { if (DataTableProducto.Rows.Count > 0) { AgregarItemAListadoDatagridView(); } } if (e.KeyCode == Keys.Escape) { listadoDataGridView.Focus(); ProductoPanel.Visible = false; } }