private void add_remainders_list_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (add_rem_name_col.Index == add_remainders_list.CurrentCell.ColumnIndex) { ComboBox cb = (ComboBox)e.Control; cb.DropDownStyle = ComboBoxStyle.DropDown; } else if (add_rem_storeid_col.Index == add_remainders_list.CurrentCell.ColumnIndex) { ComboBox StoreIdChooser = (ComboBox)e.Control; } e.Control.KeyDown -= add_list_Control_KeyDown; e.Control.KeyDown += new KeyEventHandler(add_list_Control_KeyDown); e.Control.KeyPress -= add_list_Control_KeyPress; e.Control.KeyPress += new KeyPressEventHandler(add_list_Control_KeyPress); }
private void grw_ubicaciones_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBox cajaTexto = e.Control as TextBox; if (grw_productos.CurrentCell.ColumnIndex == grw_productos.Columns["Nombre"].Index) { if (cajaTexto != null) { cajaTexto.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cajaTexto.AutoCompleteSource = AutoCompleteSource.CustomSource; cajaTexto.AutoCompleteCustomSource = autoComplete; } } else { cajaTexto.AutoCompleteCustomSource = null; } }
//taken from https://stackoverflow.com/questions/10769316/add-a-button-in-a-new-column-to-all-rows-in-a-datagrid void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is Button) { Button btn = e.Control as Button; if (btn.Name == "cmEdit") { btn.Click -= new EventHandler(On_editCheck_Click); btn.Click += new EventHandler(On_editCheck_Click); } else { btn.Click -= new EventHandler(On_delCheck_Click); btn.Click += new EventHandler(On_delCheck_Click); } } }
private void dgvData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (!this.HasAttachEvent) // 注册事件 { e.Control.KeyPress += new KeyPressEventHandler(delegate(object o, KeyPressEventArgs c) { if (dgvData.Columns[dgvData.CurrentCell.ColumnIndex].Name == "QUANTITY") { InputDouble(o, c); } else { return; } }); this.HasAttachEvent = true; } }
private void dtgvDanhSachSanPham_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { ComboBox combo = e.Control as ComboBox; if (combo != null) { // Remove an existing event-handler, if present, to avoid // adding multiple handlers when the editing control is reused. combo.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); // Add the event handler. combo.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); e.CellStyle.BackColor = this.dtgvDanhSachSanPham.DefaultCellStyle.BackColor; } }
void HandleEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { var xCol = CurrentCell.OwningColumn as XDataGridViewColumn; if (xCol != null && xCol.Field.SourceMode == SourceMode.Append) { var tBox = e.Control as TextBox; tBox.Multiline = false; tBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; tBox.AutoCompleteSource = AutoCompleteSource.CustomSource; tBox.AutoCompleteCustomSource = xCol.Field.Source; } else { var tBox = e.Control as TextBox; tBox.AutoCompleteCustomSource = null; } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridViewColumnCollection columns = this.dataGridView1.Columns; switch (columns[this.dataGridView1.CurrentCell.ColumnIndex].Name) { case "气密性": if (e.Control is TextBox) { TextBox tb = e.Control as TextBox; tb.KeyPress -= new KeyPressEventHandler(tb_KeyPress); tb.KeyPress += new KeyPressEventHandler(tb_KeyPress); } break; } }
private void dg_Dividends_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { // Allow Function Keys to work on Bloomberg Tickers // Local Variables DataGridView dg = (DataGridView)sender; if (dg.CurrentCell.OwningColumn.Name.ToUpper().Contains("TICKER")) { // Allow for the capture of Bloomberg Function Keys while in Cell Edit mode. e.Control.PreviewKeyDown -= new PreviewKeyDownEventHandler(SystemLibrary.BBGOnPreviewKeyDown); e.Control.PreviewKeyDown += new PreviewKeyDownEventHandler(SystemLibrary.BBGOnPreviewKeyDown); } else { e.Control.PreviewKeyDown -= new PreviewKeyDownEventHandler(SystemLibrary.BBGOnPreviewKeyDown); } } //dg_Dividends_EditingControlShowing()
private void jm_dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //列的索引根据自己的网格来 if (jm_dgv.CurrentCell.RowIndex >= 0) { if (jm_dgv.CurrentCell.ColumnIndex == 2) { //还原控件并绑定事件 ((ComboBox)e.Control).SelectedIndexChanged += new EventHandler(UC_Main_SelectedIndexChanged); } else if (jm_dgv.CurrentCell.ColumnIndex == 3) { //还原控件并绑定事件 ((TextBox)e.Control).TextChanged += new EventHandler(UC_Main_TextChanged); ((TextBox)e.Control).KeyPress += new KeyPressEventHandler(UC_Main_KeyPress); } } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView oDgv = sender as DataGridView; ComboBox combo = e.Control as ComboBox; if (oDgv.Focused && oDgv.CurrentCell is DataGridViewTextBoxCell && oDgv.CurrentCell.ColumnIndex == 1) { e.Control.KeyDown -= new KeyEventHandler(core.txtWin_KeyDownOEM); e.Control.KeyDown += new KeyEventHandler(core.txtWin_KeyDownOEM); e.Control.KeyPress -= new KeyPressEventHandler(core.txtWin_KeyPress); e.Control.KeyPress += new KeyPressEventHandler(core.txtWin_KeyPress); } else if (combo != null) { combo.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); combo.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); } }
/// <summary> /// Product grid view Editing control showing event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DgProductGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is DataGridViewTextBoxEditingControl) { DataGridView dg = (DataGridView)sender; //get control from the event args DataGridViewTextBoxEditingControl tb = (DataGridViewTextBoxEditingControl)e.Control; //delete event handler tb.KeyPress -= new KeyPressEventHandler(DgProductGrid_KeyPress); //only when specific column is currently editing if (dg.CurrentCell.OwningColumn.Name == AppResources.NAME_GRID_HEADER_NAME_RET_PRICE) { tb.KeyPress += new KeyPressEventHandler(DgProductGrid_KeyPress); } } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { BeginInvoke(new Action(() => { string productName = dataGridView1.CurrentRow.Cells[1].FormattedValue.ToString(); if (dataGridView1.CurrentCell.ColumnIndex == 1) { using (DBEntities db = new DBEntities()) { var v = from s in db.Stocks select s.stockName; AutoCompleteStringCollection source = new AutoCompleteStringCollection(); source.AddRange(v.ToArray()); TextBox txtBusID = e.Control as TextBox; if (txtBusID != null) { txtBusID.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtBusID.AutoCompleteCustomSource = source; txtBusID.AutoCompleteSource = AutoCompleteSource.CustomSource; } } } e.Control.KeyPress -= new KeyPressEventHandler(Column1_KeyPress); if (dataGridView1.CurrentCell.ColumnIndex == 2 || dataGridView1.CurrentCell.ColumnIndex == 3) //Desired Column { TextBox tb = e.Control as TextBox; if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column1_KeyPress); } } })); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Occurs when a control for editing a cell is showing. In this event /// a check is first made to ensure there is a current row in the DataGridView /// where if all rows were removed there is no current row. If there is a current /// row determine which column and column type followed inspecting values and /// if a numeric column setup an event to allow only numbers. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentRow != null) { _currentIndex = dataGridView1.CurrentRow.Index; } if (e.Control is CalendarEditingControl calendar) { /* * there is only one here so this assertion is not needed but if there * were more calendar columns then assertion is needed */ if (dataGridView1.CurrentCell.OwningColumn.Name == "StartDateColumn") { if (dataGridView1.CurrentRow != null) { var value = _bindingListRooms.StartDate(_currentIndex); Console.WriteLine($"EditingControlShowing {value:d}"); } } } if (e.Control is TimeEditingControl) { if (dataGridView1.CurrentRow != null) { var value = _bindingListRooms.StartTime(_currentIndex); Console.WriteLine($"{value:T}"); } } if (e.Control is DataGridViewTextBoxEditingControl) { if (dataGridView1.CurrentCell.OwningColumn.Name == "RoomIdentifierColumn") { e.Control.KeyPress -= RoomNumberNumericOnly_KeyPress; if (e.Control is TextBox tb) { tb.KeyPress += RoomNumberNumericOnly_KeyPress; } } } }
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBox tb = (e.Control as TextBox); tb.AutoCompleteCustomSource = null; AutoCompleteStringCollection acsc; if (tb == null) { return; } switch (dataGridView1.CurrentCell.OwningColumn.Name) { case "产品代码": acsc = new AutoCompleteStringCollection(); acsc.AddRange(ls存货代码.ToArray()); tb.AutoCompleteCustomSource = acsc; tb.AutoCompleteSource = AutoCompleteSource.CustomSource; tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; break; //case "存货名称": // acsc = new AutoCompleteStringCollection(); // acsc.AddRange(ls存货名称.ToArray()); // tb.AutoCompleteCustomSource = acsc; // tb.AutoCompleteSource = AutoCompleteSource.CustomSource; // tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; // break; //case "规格型号": // acsc = new AutoCompleteStringCollection(); // acsc.AddRange(ls规格型号.ToArray()); // tb.AutoCompleteCustomSource = acsc; // tb.AutoCompleteSource = AutoCompleteSource.CustomSource; // tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; // break; case "采购订单号": acsc = new AutoCompleteStringCollection(); acsc.AddRange(ls采购订单合同号.ToArray()); tb.AutoCompleteCustomSource = acsc; tb.AutoCompleteSource = AutoCompleteSource.CustomSource; tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; break; } }
/// <summary> /// 表格只输入数值类型的处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //只对TextBox类型的单元格进行验证 if (e.Control.GetType().BaseType.Name == "TextBox") { control = new TextBox(); control = (TextBox)e.Control; control.KeyPress += new KeyPressEventHandler(control_KeyPress); //if(control.Text == "") //需要限制输入数字的单元格 //{ // control.KeyPress += new KeyPressEventHandler(control_KeyPress); //} //else //{ // //非数字类型单元格 // control.Leave += new EventHandler(control_Leave); //} } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 7) { (e.Control as TextBox).Multiline = false; (e.Control as TextBox).AutoCompleteMode = AutoCompleteMode.SuggestAppend; (e.Control as TextBox).AutoCompleteSource = AutoCompleteSource.CustomSource; (e.Control as TextBox).AutoCompleteCustomSource = aut; } if (e.Control is ComboBox) { // remove handler first to avoid attaching twice ((ComboBox)e.Control).SelectedIndexChanged -= Form1_SelectedIndexChanged; ((ComboBox)e.Control).SelectedIndexChanged += Form1_SelectedIndexChanged; } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dgv = (sender as DataGridView); if (dgv.SelectedCells.Count == 0) { return; } int colIdx = dgv.SelectedCells[0].ColumnIndex; if (colIdx == 3)//分切前产品代码 { TextBox tb = (e.Control as TextBox); tb.AutoCompleteCustomSource = null; AutoCompleteStringCollection acsc; if (tb == null) { return; } acsc = new AutoCompleteStringCollection(); acsc.AddRange(hs产品代码.ToArray()); tb.AutoCompleteCustomSource = acsc; tb.AutoCompleteSource = AutoCompleteSource.CustomSource; tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; } //if (((DataGridView)sender).SelectedCells.Count <= 0) // return; //if (((DataGridView)sender).SelectedCells[0].ColumnIndex == 3) //{ // //ComboBox c = e.Control as ComboBox; // //if (c != null) c.DropDownStyle = ComboBoxStyle.DropDown; // TextBox tb = (e.Control as TextBox); // tb.AutoCompleteCustomSource = null; // AutoCompleteStringCollection acsc; // if (tb == null) return; // acsc = new AutoCompleteStringCollection(); // acsc.AddRange(hs产品代码.ToArray()); // tb.AutoCompleteCustomSource = acsc; // tb.AutoCompleteSource = AutoCompleteSource.CustomSource; // tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //} }
void table_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { if (this.table.CurrentCell.ColumnIndex == 0) { ComboBox c = e.Control as ComboBox; c.DropDownStyle = ComboBoxStyle.DropDown; c.AutoCompleteMode = AutoCompleteMode.Suggest; c.AutoCompleteSource = AutoCompleteSource.ListItems; } if ((sender as DataGridView).CurrentCell.ColumnIndex == 0) { (e.Control as ComboBox).SelectedIndexChanged += new EventHandler(InsertCodeOKP); } } catch { } }
private void cashierDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { // += if ((ProductBCGridView.CurrentCell.OwningColumn.Name == "productID") && e.Control is TextBox) { TextBox productIDTextBox = e.Control as TextBox; productIDTextBox.CharacterCasing = CharacterCasing.Upper; productIDTextBox.PreviewKeyDown -= Combobox_previewKeyDown; productIDTextBox.PreviewKeyDown += Combobox_previewKeyDown; productIDTextBox.AutoCompleteMode = AutoCompleteMode.None; productIDTextBox.KeyUp += Combobox_KeyUp; } if ((ProductBCGridView.CurrentCell.OwningColumn.Name == "productName") && e.Control is TextBox) { TextBox productNameTextBox = e.Control as TextBox; productNameTextBox.CharacterCasing = CharacterCasing.Upper; productNameTextBox.PreviewKeyDown -= productName_previewKeyDown; productNameTextBox.PreviewKeyDown += productName_previewKeyDown; productNameTextBox.AutoCompleteMode = AutoCompleteMode.None;//SuggestAppend; productNameTextBox.KeyUp += Combobox_KeyUp; } if ((ProductBCGridView.CurrentCell.OwningColumn.Name == "productPrice") && e.Control is TextBox) { TextBox productRetailTextBox = e.Control as TextBox; productRetailTextBox.CharacterCasing = CharacterCasing.Upper; productRetailTextBox.AutoCompleteMode = AutoCompleteMode.None; productRetailTextBox.KeyUp += Combobox_KeyUp; } if ((ProductBCGridView.CurrentCell.OwningColumn.Name == "productBarcode") && e.Control is TextBox) { TextBox productBarcodeTextBox = e.Control as TextBox; productBarcodeTextBox.CharacterCasing = CharacterCasing.Upper; productBarcodeTextBox.AutoCompleteMode = AutoCompleteMode.None; productBarcodeTextBox.KeyUp += Combobox_KeyUp; } }
private void dgvItems_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBox celda = e.Control as TextBox; ArticuloPlanta artPla = (ArticuloPlanta)dgvItems.Rows[dgvItems.CurrentCell.RowIndex].Tag; switch (dgvItems.CurrentCell.OwningColumn.Name) { case "clmArt": Cargador.cargarArticuloPlanta(celda, planta); break; case "clmDesc": Cargador.cargarArticulosDePlanta(celda, planta); break; case "clmLote": if (artPla != null) { Cargador.cargarLotes(celda, artPla.TipoArticulo, 0); } break; case "clmPresent": Cargador.cargarPresentaciones(celda); break; case "clmPrecio": if (artPla != null) { Cargador.cargarPrecios(celda, artPla); } break; default: var lista = new List <string>(); AutoCompleteStringCollection listaAuto = new AutoCompleteStringCollection(); listaAuto.AddRange(lista.ToArray()); celda.AutoCompleteCustomSource = listaAuto; celda.AutoCompleteMode = AutoCompleteMode.SuggestAppend; celda.AutoCompleteSource = AutoCompleteSource.CustomSource; break; } }
//Autocomplete Code for the Gender and Stream Text Boxes private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBox txtB = e.Control as TextBox; //Column Index of Gender Column is 4 if (dataGridView1.CurrentCell.ColumnIndex == 4 && txtB != null) { txtB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtB.AutoCompleteSource = AutoCompleteSource.CustomSource; txtB.AutoCompleteCustomSource.AddRange(new string[] { "Male", "Female" }); } //Column Index of Stream Column is 5 else if (dataGridView1.CurrentCell.ColumnIndex == 5 && txtB != null) { txtB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtB.AutoCompleteSource = AutoCompleteSource.CustomSource; txtB.AutoCompleteCustomSource.AddRange(new string[] { "Science", "Commerce", "Humanities" }); } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { if (dataGridView1.CurrentCell.ColumnIndex == 0) { TextBox autoText = e.Control as TextBox; autoText.AutoCompleteMode = AutoCompleteMode.Suggest; autoText.AutoCompleteSource = AutoCompleteSource.CustomSource; AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection(); DataCollection.AddRange(Products.Select(n => n.Name).ToArray()); autoText.AutoCompleteCustomSource = DataCollection; } } catch (Exception ex) { BusinessModel.Log.Logger(ex); } }
private void dgvSaleItems_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { e.Control.KeyPress -= new KeyPressEventHandler(Column1_KeyPress); if (dgvSaleItems.CurrentCell.ColumnIndex == 3 || dgvSaleItems.CurrentCell.ColumnIndex == 5 || dgvSaleItems.CurrentCell.ColumnIndex == 7 || dgvSaleItems.CurrentCell.ColumnIndex == 9 || dgvSaleItems.CurrentCell.ColumnIndex == 11) //Desired Column { TextBox tb = e.Control as TextBox; if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column1_KeyPress); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void DGView_WatchList_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { var gview = sender as DataGridView; if (gview == null) { return; } var row_obj = gview.Rows[gview.CurrentCell.RowIndex]; var cell_obj = row_obj.Cells[gview.CurrentCell.ColumnIndex]; switch ((ColumnId)gview.CurrentCell.ColumnIndex) { case ColumnId.Expression: DGView_CmdList_EditCell_Command(gview.EditingControl as DataGridViewTextBoxEditingControl, row_obj, cell_obj); break; } }
//void cbm_SelectedIndexChanged(object sender, EventArgs e) //{ // this.BeginInvoke(new MethodInvoker(EndEdit)); //} // ComboBox cbm; // DataGridViewCell currentCell; // private DateTimePicker cellDateTimePicker = new DateTimePicker(); // DateTimePicker[] sp = new DateTimePicker[100]; //void EndEdit() //{ // //if (cbm != null) // //{ // // if (cbm.SelectedItem != null) // // { // // string SelectedItem = (cbm.SelectedItem as ComboboxItem).Value.ToString();// (cbm.SelectedItem as ComboboxItem).Value.ToString(); // // // int i = dataGridProgramdetail.CurrentRow.Index; // // int i = currentCell.RowIndex; // // string colname = this.dataGridViewDetail.Columns[this.dataGridViewDetail.CurrentCell.ColumnIndex].Name; // // dataGridViewDetail.Rows[i].Cells[colname].Value = SelectedItem; // // } // //} //} private void dataGridViewTkCo_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //if (e.Control is ComboBox) //{ // cbm = (ComboBox)e.Control; // if (cbm != null) // { // cbm.SelectedIndexChanged += new EventHandler(cbm_SelectedIndexChanged); // } // currentCell = this.dataGridViewDetail.CurrentCell; //} }
private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { var dgv = sender as DataGridView; if (dgv.CurrentCell.ColumnIndex == 0) { TextBox a = e.Control as TextBox; if (a != null) { a.AutoCompleteMode = AutoCompleteMode.SuggestAppend; a.AutoCompleteSource = AutoCompleteSource.CustomSource; AutoCompleteStringCollection sc = new AutoCompleteStringCollection(); sc.AddRange(citizenNames); //foreach (var i in citizenNames) // sc.Add(i.Replace(',', ' ')); a.AutoCompleteCustomSource = sc; } } }
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridViewCell currCell = this.dgvProductList.CurrentCell; if (currCell == null || currCell.ColumnIndex == this.colNameShort.Index) { return; } TextBox textBoxExitingControl = e.Control as TextBox; if (textBoxExitingControl == null || textBoxExitingControl.IsDisposed) { return; } textBoxExitingControl.ImeMode = ImeMode.Alpha; textBoxExitingControl.KeyPress -= new KeyPressEventHandler(this.TextBoxExitingControl_KeyPress); textBoxExitingControl.KeyPress += new KeyPressEventHandler(this.TextBoxExitingControl_KeyPress); }
private void modifica_dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (lista_modifica.SelectedItem.ToString() != lista_modifica.Items[0].ToString()) { return; } if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl)) { ComboBox comboBox = (ComboBox)e.Control; if (comboBox != null) { save_comboBox = comboBox.SelectedIndex + 1; comboBox.MouseDown -= new MouseEventHandler(m_ComboBoxColumn_MouseDown); comboBox.MouseDown += new MouseEventHandler(m_ComboBoxColumn_MouseDown); comboBox.SelectedIndexChanged -= new EventHandler(m_ComboBoxColumn_SelectedIndexChanged); comboBox.SelectedIndexChanged += new EventHandler(m_ComboBoxColumn_SelectedIndexChanged); } } }
private void dataGridView2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { String header = dataGridView2.Columns[1].HeaderText; if (header.Equals("Product Name")) { TextBox productName = e.Control as TextBox; if (productName != null) { productName.AutoCompleteMode = AutoCompleteMode.SuggestAppend; AutoCompleteStringCollection stringCollection = new AutoCompleteStringCollection(); FillItems(stringCollection); productName.AutoCompleteCustomSource = stringCollection; productName.AutoCompleteSource = AutoCompleteSource.CustomSource; setRowNumber(dataGridView2); } } }
private void dgChiTiet_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (!_isNew) { return; } if (dgChiTiet.CurrentCell.ColumnIndex == 5) { TextBox textBox = e.Control as TextBox; if (textBox != null) { textBox.KeyPress -= new KeyPressEventHandler(textBox_KeyPress); textBox.TextChanged -= new EventHandler(textBox_TextChanged); textBox.KeyPress += new KeyPressEventHandler(textBox_KeyPress); textBox.TextChanged += new EventHandler(textBox_TextChanged); } } }