void CreateEditingControl () { editingControl = new DataGridViewTextBoxEditingControl() { Multiline = false, BorderStyle = BorderStyle.None }; }
private void dgMonitorEditorView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { Control control = e.Control; if (control is System.Windows.Forms.DataGridViewTextBoxEditingControl) { System.Windows.Forms.DataGridViewTextBoxEditingControl editor = control as System.Windows.Forms.DataGridViewTextBoxEditingControl; editor.TextChanged -= new EventHandler(editor_TextChanged); editor.TextChanged += new EventHandler(editor_TextChanged); } }
/// <summary> /// 限制DataGridView文本框为数量和价格时,数量不可以超出指定的范围 /// </summary> /// <param name="sender"></param> /// <param name="Num"></param> public static void GridViewTextBoxChangedFolat(DataGridViewTextBoxEditingControl sender, decimal Num) { try { if (sender.Text.Trim().Length > 0) { decimal result=0; if (decimal.TryParse(sender.Text.Trim(), out result)) { if (Math.Abs(result) > Num) { sender.Text = sender.Text.Trim().Substring(0, sender.Text.Trim().Length - 1); sender.SelectionStart = sender.Text.Trim().Length; } } } } catch (Exception ex) { } }
public DataGridViewTextBoxEditingControlAccessibleObject(DataGridViewTextBoxEditingControl ownerControl) : base(ownerControl) { _owningDataGridViewTextBoxEditingControl = ownerControl; _textProvider = new TextBoxBaseUiaTextProvider(ownerControl); UseTextProviders(_textProvider, _textProvider); }
void UpdateEditColumnDisplay(DataGridViewTextBoxEditingControl editControl) { // prevents key events after edit mode has ended if (dataGridView.EditingControl != null) { int pos = editControl.SelectionStart + editControl.SelectionLength; StatusLineText(" " + pos); Logger.logDebug("SelStart: " + editControl.SelectionStart + ", SelLen: " + editControl.SelectionLength); } }
/// <summary> /// grid EditingControlShowing event To handle the keypress event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalesInvoice_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { if (dgvSalesInvoice.CurrentCell != null && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name == "dgvtxtSalesInvoiceProductName") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductNames; } if (dgvSalesInvoice.CurrentCell != null && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name == "dgvtxtSalesInvoiceProductCode") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductCodes; } if (dgvSalesInvoice.CurrentCell != null && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name == "dgvtxtSalesInvoiceBarcode") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductCodes; } if (dgvSalesInvoice.CurrentCell != null && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name != "dgvtxtSalesInvoiceProductCode" && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name != "dgvtxtSalesInvoiceProductName" && dgvSalesInvoice.Columns[dgvSalesInvoice.CurrentCell.ColumnIndex].Name != "dgvtxtSalesInvoiceBarcode") { DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)dgvSalesInvoice.EditingControl; editControl.AutoCompleteMode = AutoCompleteMode.None; } TextBoxControl.KeyPress += TextBoxCellEditControlKeyPress; if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceQty"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountPercentage"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceRate"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceGrossValue"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvSalesInvoice.CurrentCell.ColumnIndex == dgvSalesInvoice.Columns["dgvtxtSalesInvoiceNetAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } else { TextBoxControl.KeyPress += keypresseventforOther; } } } catch (Exception ex) { MessageBox.Show("SI: 113" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
static DataGridViewTextBoxCell() { editingControl = new DataGridViewTextBoxEditingControl(); editingControl.Multiline = false; editingControl.BorderStyle = BorderStyle.None; }
/// <summary> /// Handles 'EditingControlTextChanged' & 'EditingControlKeyDown' event firing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { Type type = e.Control.GetType(); if (type.Name == "DataGridViewTextBoxEditingControl") { objEditingcontrol = (DataGridViewTextBoxEditingControl)e.Control; objEditingcontrol.TextChanged -= new EventHandler(objEditingcontrol_TextChanged); objEditingcontrol.KeyDown -= new KeyEventHandler(objEditingcontrol_KeyDown); objEditingcontrol.TextChanged += new EventHandler(objEditingcontrol_TextChanged); objEditingcontrol.KeyDown += new KeyEventHandler(objEditingcontrol_KeyDown); //objEditingcontrol.BackColor = Color.White; //message } } catch { } }
/// <summary> /// to call the validation and for calling keypress event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPurchaseOrder_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { if (dgvPurchaseOrder.CurrentCell != null && dgvPurchaseOrder.Columns[dgvPurchaseOrder.CurrentCell.ColumnIndex].Name == "dgvtxtProductName") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductNames; } if (dgvPurchaseOrder.CurrentCell != null && dgvPurchaseOrder.Columns[dgvPurchaseOrder.CurrentCell.ColumnIndex].Name == "dgvtxtProductCode") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductCodes; } if (dgvPurchaseOrder.CurrentCell != null && dgvPurchaseOrder.Columns[dgvPurchaseOrder.CurrentCell.ColumnIndex].Name != "dgvtxtProductCode" && dgvPurchaseOrder.Columns[dgvPurchaseOrder.CurrentCell.ColumnIndex].Name != "dgvtxtProductName") { DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)dgvPurchaseOrder.EditingControl; editControl.AutoCompleteMode = AutoCompleteMode.None; } TextBoxControl.KeyPress += TextBoxCellEditControlKeyPress; } } catch (Exception ex) { MessageBox.Show("PO47:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
void clsSearchGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //this.Refresh(); //Application.DoEvents(); //this.BackgroundColor = Color.White; //this.DefaultCellStyle.BackColor = Color.White; this.EnableHeadersVisualStyles = true; //this.CellPainting += new DataGridViewCellPaintingEventHandler(clsSearchGrid_CellPainting); editingcontrol=(DataGridViewTextBoxEditingControl) e.Control; editingcontrol.BackColor = Color.White; editingcontrol.BorderStyle = BorderStyle.None; editingcontrol.Dock = DockStyle.Fill; editingcontrol.PrepareEditingControlForEdit(false); editingcontrol.TextChanged += new EventHandler(editingcontrol_TextChanged); }
private void dataGridView2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { CellEdit = (DataGridViewTextBoxEditingControl)e.Control; // 赋值 CellEdit.SelectAll(); CellEdit.KeyPress += Cells_KeyPress; // 绑定到事件 }
private void dgvSubSpeedParam_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { int columnIndex = this.dgvSubSpeedParam.CurrentCell.ColumnIndex; if (this.dgvSubSpeedParam.Columns[columnIndex].Name == "TopSpeed" || this.dgvSubSpeedParam.Columns[columnIndex].Name == "HoldTime" || this.dgvSubSpeedParam.Columns[columnIndex].Name == "行驶最长时间" || this.dgvSubSpeedParam.Columns[columnIndex].Name == "行驶最短时间") { this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; this.EditingControl.KeyPress += new KeyPressEventHandler(this.EditingControl_KeyPress); } }
//int entrycount = 0; void clsSearchGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { //if (!insidetextchanged) //{ Type type = e.Control.GetType(); if (type.Name == "DataGridViewComboBoxEditingControl") { comboforall = null; comboforall = (ComboBox)e.Control; comboboolean = true; comboforall.SelectionChangeCommitted += new EventHandler(comboforall_SelectionChangeCommitted); } else if (type.Name == "DataGridViewTextBoxEditingControl") { EnableF2Event = true; editingcontrol = (DataGridViewTextBoxEditingControl)e.Control; editingcontrol.TextChanged += new EventHandler(editingcontrol_TextChanged); //entrycount = 0; editingcontrol.KeyDown += new KeyEventHandler(editingcontrol_KeyDown); } //} } catch (Exception ex) { } }
/************************************************************* * データグリッドビューの編集中のイベント追加 *************************************************************/ private void dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dgv = (DataGridView)sender; // テキストボックスのイベント追加 if (e.Control is DataGridViewTextBoxEditingControl) { dgvTextBox = (DataGridViewTextBoxEditingControl)e.Control; dgvTextBox.Leave += new EventHandler(control_Leave_calc); dgvTextBox.KeyPress += new KeyPressEventHandler(Event.textBox_KeyPress_numeric); } }
/************************************************************* * データグリッドビューの編集後のイベント削除 *************************************************************/ private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { // テキストボックスのイベント削除 if (dgvTextBox != null) { dgvTextBox.KeyPress -= new KeyPressEventHandler(Event.textBox_KeyPress_numeric); dgvTextBox.Leave -= new EventHandler(control_Leave_calc); dgvTextBox = null; } }
/// <summary> /// Calling the keypress event here /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvAdditionalCost_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; try { if (TextBoxControl != null) { if (dgvAdditionalCost.CurrentCell.ColumnIndex == dgvAdditionalCost.Columns["dgvtxtAdditionalCostAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } else { TextBoxControl.KeyPress += keypresseventforOther; } } } catch (Exception ex) { MessageBox.Show("SJ:94" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Calling the keypress event here /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvAdditionalCost_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { TextBoxControl.KeyPress += dgvAdditionalCost_KeyPress; } } catch (Exception ex) { MessageBox.Show("PI92:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void dgvClutterLoss_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { this.CellEdit = (DataGridViewTextBoxEditingControl) e.Control; this.CellEdit.SelectAll(); this.CellEdit.KeyPress += new KeyPressEventHandler(this.CellEdit_KeyPress); }
/// <summary> /// AutoCompletion of Product,productCode /// </summary> /// <param name="isProductName"></param> /// <param name="editControl"></param> public void FillProducts(bool isProductName, DataGridViewTextBoxEditingControl editControl) { try { ProductCreationBll BllProductCreation = new ProductCreationBll(); List<DataTable> listObjProducts = new List<DataTable>(); ProductNames = BllProductCreation.ProudctNameViewAllForAutoComplete(); ProductCodes = BllProductCreation.ProudctCodesViewAllForAutoComplete(); } catch (Exception ex) { MessageBox.Show("PO7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/************************************************************* * データグリッドビューの編集後のイベント削除 *************************************************************/ private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { // コンボックスのイベント削除 if (dgvComboBox != null) { dgvComboBox.SelectedIndexChanged -= new EventHandler(dgvComboBox_SelectedIndexChanged); dgvComboBox.Leave -= new EventHandler(control_Leave_calc); dgvComboBox = null; } // テキストボックスのイベント削除 if (dgvTextBox != null) { dgvTextBox.KeyPress -= new KeyPressEventHandler(Event.textBox_KeyPress_numeric); dgvTextBox.Leave -= new EventHandler(control_Leave_calc); dgvTextBox = null; } calcAll(); }
public void TestBindingToDataGridViewTextBoxEditingControl() { DataGridViewTextBoxEditingControl control = new DataGridViewTextBoxEditingControl(); IBusinessObject obj = new BusinessObject(); using(BindingScope scope = new BindingScope()) { IBusinessObject bindableSource = scope.CreateSource(obj); if(control is Control) ((Control)control).CreateControl(); control.BindingContext = new BindingContext(); DataGridViewTextBoxEditingControl bindableTarget = scope.CreateTarget(control); int dataBindingsBeforeEditingControlRowIndex = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.EditingControlRowIndex); Assert.AreEqual(dataBindingsBeforeEditingControlRowIndex + 1, control.DataBindings.Count); Assert.AreEqual(control.EditingControlRowIndex, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.EditingControlRowIndex, obj.IntValue); int dataBindingsBeforeMaxLength = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxLength); Assert.AreEqual(dataBindingsBeforeMaxLength + 1, control.DataBindings.Count); Assert.AreEqual(control.MaxLength, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.MaxLength, obj.IntValue); int dataBindingsBeforeLeft = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.Left); Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count); Assert.AreEqual(control.Left, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.Left, obj.IntValue); int dataBindingsBeforeName = control.DataBindings.Count; scope.Bind(bindableSource.Name).To(bindableTarget.Name); Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count); Assert.AreEqual(control.Name, obj.Name); obj.ChangeName(); Assert.AreEqual(control.Name, obj.Name); int dataBindingsBeforeTabIndex = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex); Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count); Assert.AreEqual(control.TabIndex, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.TabIndex, obj.IntValue); int dataBindingsBeforeTop = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.Top); Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count); Assert.AreEqual(control.Top, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.Top, obj.IntValue); int dataBindingsBeforeWidth = control.DataBindings.Count; scope.Bind(bindableSource.IntValue).To(bindableTarget.Width); Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count); Assert.AreEqual(control.Width, obj.IntValue); obj.ChangeIntValue(); Assert.AreEqual(control.Width, obj.IntValue); } }
/************************************************************* * データグリッドビューの編集中のイベント追加 *************************************************************/ private void dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dgv = (DataGridView)sender; // コンボックスのイベント追加 if (e.Control is DataGridViewComboBoxEditingControl) { if (dgv.CurrentCell.OwningColumn.Name == "dgvMaterialCostName" || dgv.CurrentCell.OwningColumn.Name == "dgvPackingName" || dgv.CurrentCell.OwningColumn.Name == "dgvMachineName" || dgv.CurrentCell.OwningColumn.Name == "dgvPackingFareName") { dgvComboBox = (DataGridViewComboBoxEditingControl)e.Control; dgvComboBox.SelectedIndexChanged += new EventHandler(dgvComboBox_SelectedIndexChanged); dgvComboBox.Leave += new EventHandler(control_Leave_calc); } } // テキストボックスのイベント追加 if (e.Control is DataGridViewTextBoxEditingControl) { dgvTextBox = (DataGridViewTextBoxEditingControl)e.Control; dgvTextBox.Leave += new EventHandler(control_Leave_calc); if (dgv.CurrentCell.OwningColumn.Name == "dgvMaterialCostQuantity" || dgv.CurrentCell.OwningColumn.Name == "dgvContractorsQuantity" || dgv.CurrentCell.OwningColumn.Name == "dgvContractorsCost" || dgv.CurrentCell.OwningColumn.Name == "dgvMaterialsFareQuantity" || dgv.CurrentCell.OwningColumn.Name == "dgvMaterialsFareCost" || dgv.CurrentCell.OwningColumn.Name == "dgvPackingQuantity" || dgv.CurrentCell.OwningColumn.Name == "dgvMachineTime" || dgv.CurrentCell.OwningColumn.Name == "dgvPackingFareQuantity") { dgvTextBox.KeyPress += new KeyPressEventHandler(Event.textBox_KeyPress_numeric); } } }
/// <summary> /// Fill the product name and the code for auto completeion /// </summary> /// <param name="isProductName"></param> /// <param name="editControl"></param> public void FillProducts(bool isProductName, DataGridViewTextBoxEditingControl editControl) { ProductSP spProduct = new ProductSP(); try { DataTable dtblProducts = new DataTable(); dtblProducts = spProduct.ProductViewAll(); ProductNames = new AutoCompleteStringCollection(); ProductCodes = new AutoCompleteStringCollection(); foreach (DataRow dr in dtblProducts.Rows) { ProductNames.Add(dr["productName"].ToString()); ProductCodes.Add(dr["productCode"].ToString()); } } catch (Exception ex) { MessageBox.Show("SI: 61" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/************************************************************* * データグリッドビューの編集後のイベント削除 *************************************************************/ protected void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = (DataGridView)sender; // テキストボックスのイベント削除 if (dgvTextBox != null) { dgvTextBox.KeyPress -= new KeyPressEventHandler(Event.textBox_KeyPress_numeric); if (dgv.Name.Equals(dataGridView.Name)) dgvTextBox.Leave -= new EventHandler(dataGridView_Leave); dgvTextBox = null; } }
/// <summary> /// Calling the keypress event here /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalesInvoiceLedger_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { if (dgvSalesInvoiceLedger.CurrentCell.ColumnIndex == dgvSalesInvoiceLedger.Columns["dgvtxtAdditionalCoastledgerAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } } } catch (Exception ex) { MessageBox.Show("SI: 125" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/************************************************************* * データグリッドビューの編集中のイベント追加 *************************************************************/ protected void dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dgv = (DataGridView)sender; // テキストボックスのイベント追加 if (e.Control is DataGridViewTextBoxEditingControl) { dgvTextBox = (DataGridViewTextBoxEditingControl)e.Control; dgvTextBox.KeyPress += new KeyPressEventHandler(Event.textBox_KeyPress_numeric); if (dgv.Name.Equals(dataGridView.Name)) dgvTextBox.Leave += new EventHandler(dataGridView_Leave); } }
public DataGridViewTextBoxEditingControlAccessibleObject(DataGridViewTextBoxEditingControl ownerControl) : base(ownerControl) { this.ownerControl = ownerControl; }
/// <summary> /// Calls keypress event and autocompletion /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduct_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { if (dgvProduct.CurrentCell != null && dgvProduct.Columns[dgvProduct.CurrentCell.ColumnIndex].Name == "dgvtxtProductName") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductName; } else if (dgvProduct.CurrentCell != null && dgvProduct.Columns[dgvProduct.CurrentCell.ColumnIndex].Name == "dgvtxtProductCode") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductCode; } if (dgvProduct.CurrentCell != null && dgvProduct.Columns[dgvProduct.CurrentCell.ColumnIndex].Name != "dgvtxtProductName" && dgvProduct.Columns[dgvProduct.CurrentCell.ColumnIndex].Name != "dgvtxtProductCode") { DataGridViewTextBoxEditingControl editcontrol = (DataGridViewTextBoxEditingControl)dgvProduct.EditingControl; editcontrol.AutoCompleteMode = AutoCompleteMode.None; } TextBoxControl.KeyPress += TextBoxCellEditControlKeyPress; } if (e.Control is DataGridViewTextBoxEditingControl) { DataGridViewTextBoxEditingControl tb = e.Control as DataGridViewTextBoxEditingControl; tb.KeyDown -= dgvProduct_KeyDown; tb.KeyDown += new KeyEventHandler(dgvProduct_KeyDown); } } catch (Exception ex) { MessageBox.Show("SQ:57" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
static DataGridViewTextBoxCell () { editingControl = new DataGridViewTextBoxEditingControl(); editingControl.Multiline = false; editingControl.BorderStyle = BorderStyle.None; }
/// <summary> /// Function to fill product,product code autocompletion /// </summary> /// <param name="isBatchName"></param> /// <param name="editControl"></param> public void FillBatch(bool isBatchName, DataGridViewTextBoxEditingControl editControl) { try { BatchSP spBatch = new BatchSP(); DataTable dtblBatch = new DataTable(); Batch = spBatch.BatchViewAllWithoutNA(); } catch (Exception ex) { MessageBox.Show("PO4:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// grid EditingControlShowing event To handle the keypress event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduction_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; try { if (TextBoxControl != null) { if (dgvProduction.CurrentCell != null && dgvProduction.Columns[dgvProduction.CurrentCell.ColumnIndex].Name == "dgvtxtProductionProductName") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductNames; } if (dgvProduction.CurrentCell != null && dgvProduction.Columns[dgvProduction.CurrentCell.ColumnIndex].Name == "dgvtxtProductionProductCode") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = ProductCodes; } if (dgvProduction.CurrentCell != null && dgvProduction.Columns[dgvProduction.CurrentCell.ColumnIndex].Name != "dgvtxtProductionProductCode" && dgvProduction.Columns[dgvProduction.CurrentCell.ColumnIndex].Name != "dgvtxtProductionProductName") { DataGridViewTextBoxEditingControl editControl = (DataGridViewTextBoxEditingControl)dgvProduction.EditingControl; editControl.AutoCompleteMode = AutoCompleteMode.None; } if (dgvProduction.CurrentCell.ColumnIndex == dgvProduction.Columns["dgvtxtProductionQty"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvProduction.CurrentCell.ColumnIndex == dgvProduction.Columns["dgvtxtProductionRate"].Index) { TextBoxControl.KeyPress += keypressevent; } else if (dgvProduction.CurrentCell.ColumnIndex == dgvProduction.Columns["dgvtxtProductionAmount"].Index) { TextBoxControl.KeyPress += keypressevent; } else { TextBoxControl.KeyPress += keypresseventforOther; } } } catch (Exception ex) { MessageBox.Show("SJ:70" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Work on dgvProductCreation EditingControlShowing event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProductCreation_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { DataGridViewTextBoxEditingControl dgvtxtqty = e.Control as DataGridViewTextBoxEditingControl; DataGridViewTextBoxEditingControl dgvtxtrate = e.Control as DataGridViewTextBoxEditingControl; if (dgvtxtqty != null) { dgvtxtqty.KeyPress += dgvtxtqty_KeyPress; } if (dgvtxtrate != null) { dgvtxtrate.KeyPress += dgvtxtrate_KeyPress; } if (e.Control is ComboBox) { //SendKeys.Send("{F4}"); //e.Control.KeyPress += gridCombo_KeyPress; } TextBoxControl = e.Control as DataGridViewTextBoxEditingControl; if (TextBoxControl != null) { if (dgvProductCreation.CurrentCell != null && dgvProductCreation.Columns[dgvProductCreation.CurrentCell.ColumnIndex].Name == "dgvtxtbatch") { TextBoxControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend; TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource; TextBoxControl.AutoCompleteCustomSource = Batch; } } } catch (Exception ex) { MessageBox.Show("PC:113" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// AutoCompletion of Product name and Product code /// </summary> /// <param name="isProductName"></param> /// <param name="editControl"></param> public void FillProducts(bool isProductName, DataGridViewTextBoxEditingControl editControl) { try { List<DataTable> listObjProducts = new List<DataTable>(); listObjProducts = new ProductCreationBll().ProductViewAll(); ProductNames = new AutoCompleteStringCollection(); ProductCodes = new AutoCompleteStringCollection(); foreach (DataRow dr in listObjProducts[0].Rows) { ProductNames.Add(dr["productName"].ToString()); ProductCodes.Add(dr["productCode"].ToString()); } } catch (Exception ex) { MessageBox.Show("DN15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// AutoCompletion of Product,productCode /// </summary> /// <param name="isProductName"></param> /// <param name="editControl"></param> public void FillProducts(bool isProductName, DataGridViewTextBoxEditingControl editControl) { try { ProductSP spProduct = new ProductSP(); DataTable dtblProducts = new DataTable(); ProductNames = spProduct.ProudctNameViewAllForAutoComplete(); ProductCodes = spProduct.ProudctCodesViewAllForAutoComplete(); } catch (Exception ex) { MessageBox.Show("PO7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }