public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { // Set the value of the editing control to the current cell value. switch (csdgCellType) { case CSDGCellTypeEnum.Combo: case CSDGCellTypeEnum.ComboText: base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); DataGridViewComboBoxEditingControl ctl2 = DataGridView.EditingControl as DataGridViewComboBoxEditingControl; ctl2.DropDownStyle = ComboBoxStyle.DropDownList; ctl2.Items.Clear(); ctl2.Items.AddRange(cboItems); if (this.Value == null) { ctl2.SelectedIndex = -1; } else { for (int i = 0; i < ctl2.Items.Count; i++) { if (ctl2.Items[i].ToString() == this.Value.ToString()) { ctl2.SelectedIndex = i; } } } break; case CSDGCellTypeEnum.Date: base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); CalendarEditingControl ctl = DataGridView.EditingControl as CalendarEditingControl; // Use the default row value when Value property is null. if (this.Value == null) { ctl.Value = (DateTime)this.DefaultNewRowValue; } else { ctl.Value = Convert.ToDateTime(this.Value); } break; case CSDGCellTypeEnum.Label: break; default: base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); DataGridViewTextBoxEditingControl ctl1 = DataGridView.EditingControl as DataGridViewTextBoxEditingControl; if (this.Value == null) { ctl1.Text = ""; } else { ctl1.Text = this.Value.ToString(); } break; } }
private void ValidateDropdown(object sender, CancelEventArgs e) { DataGridViewComboBoxEditingControl control = sender as DataGridViewComboBoxEditingControl; string value = control.Text; var exists = control.Items .Cast <InvoiceItemDescriptionDTO>() .FirstOrDefault(iid => iid.Value.ToUpperInvariant() == value.Trim().ToUpperInvariant()); if (exists == null) { DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)invoiceItemsDataGridView.CurrentCell; InvoiceItemDescriptions.Add( new InvoiceItemDescriptionDTO() { Value = value.Trim().ToUpperInvariant() } ); invoiceItemsDataGridView.CurrentCell.Value = value.Trim().ToUpperInvariant(); } if (exists != null) { var invoiceItem = invoiceItemsDataGridView.CurrentCell.OwningRow.DataBoundItem as InvoiceItem; if (invoiceItem != null) { invoiceItem.Code = exists.Code; } } }
private void dataGridViewCuentas_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { int iColumn = dataGridViewCuentas.CurrentCell.ColumnIndex; if (iColumn == (int)col_Grid.NROCUENTA) { TextBox txt = e.Control as TextBox; txt.KeyPress += OnlyNumbers_KeyPress; } //VERIFICA SI CAMBIA LA CUENTA... if (iColumn == (int)col_Grid.DESCRIP_CTA) { dgvCombo = e.Control as DataGridViewComboBoxEditingControl; if (dgvCombo != null) { dgvCombo.SelectedIndexChanged += new EventHandler(dvgCombo_SelectedIndexChanged); } } if (e.Control is DataGridViewTextBoxEditingControl && iColumn == (int)col_Grid.ARTICULO) { DataGridViewTextBoxEditingControl tb = e.Control as DataGridViewTextBoxEditingControl; tb.KeyPress -= dataGridViewCuentas_KeyPress; tb.KeyPress += new KeyPressEventHandler(dataGridViewCuentas_KeyPress); } }
private void gridViewFilter_CellClick(object sender, DataGridViewCellEventArgs e) { //if (e.ColumnIndex == gridViewFilter.Columns["Delete"].Index) //{ // gridViewFilter.Rows.RemoveAt(e.RowIndex); //} // if this isn't a valid cell location, leave now if ((e.RowIndex < 0) || (e.ColumnIndex < 0)) { return; } // get the row, and then the cell, of the clicked cell var row = gridViewFilter.Rows[e.RowIndex]; var cell = row.Cells[e.ColumnIndex]; // if the cell is a combobox, make it drop down if (cell is DataGridViewComboBoxCell) { DataGridViewComboBoxEditingControl comboboxEdit = (DataGridViewComboBoxEditingControl)gridViewFilter.EditingControl; if (comboboxEdit != null) { comboboxEdit.DroppedDown = true; } } }
private void grdOptions_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { foreach (DataGridViewRow row in grdOptions.SelectedRows) { OMLMetadataOption option = row.Tag as OMLMetadataOption; if (!option.AllowOnlyPossibleValues) { DataGridViewComboBoxEditingControl comboControl = e.Control as DataGridViewComboBoxEditingControl; if (comboControl != null) { comboControl.DropDownStyle = ComboBoxStyle.DropDown; } } } /* DataGridViewComboBoxEditingControl comboControl * = e.Control as DataGridViewComboBoxEditingControl; * if (comboControl != null) * { * // Set the DropDown style to get an editable ComboBox * if (comboControl.DropDownStyle != ComboBoxStyle.DropDown) * { * comboControl.DropDownStyle = ComboBoxStyle.DropDown; * } * }*/ }
private void MaterialCheckForm_SelectedIndexChanged(object sender, EventArgs e) { int RowIndex = dataGridView_Param.CurrentCell.RowIndex; int ColumnIndex = dataGridView_Param.CurrentCell.ColumnIndex; string str = ParamSetUnit.boolUnit.ToString(); DataGridViewComboBoxEditingControl gridView = (DataGridViewComboBoxEditingControl)sender; if (gridView.SelectedItem.ToString() == "boolUnit") { dataGridView_Param.Rows[RowIndex].Cells[3].Value = "True"; dataGridView_Param.Rows[RowIndex].Cells[4].Value = "False"; } else if (gridView.SelectedItem.ToString() == "stringUnit") { dataGridView_Param.Rows[RowIndex].Cells[3].Value = "None"; dataGridView_Param.Rows[RowIndex].Cells[4].Value = "None"; } DataGridViewComboBoxColumn combox1 = (DataGridViewComboBoxColumn)dataGridView_Param.Columns[5]; dataGridView_Param.Rows[RowIndex].Cells[5].Value = combox1.Items[3]; DataGridViewComboBoxColumn combox2 = (DataGridViewComboBoxColumn)dataGridView_Param.Columns[6]; if (RowIndex < 1) { dataGridView_Param.Rows[RowIndex].Cells[5].Value = combox1.Items[1]; dataGridView_Param.Rows[RowIndex].Cells[6].Value = combox2.Items[0]; } else { dataGridView_Param.Rows[RowIndex].Cells[5].Value = dataGridView_Param.Rows[RowIndex - 1].Cells[5].Value; dataGridView_Param.Rows[RowIndex].Cells[6].Value = dataGridView_Param.Rows[RowIndex - 1].Cells[6].Value; } }
private void dgrProperties_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1 && e.RowIndex == 2) { FeaturesForm featuresForm = new FeaturesForm(); Point pointToScreen = PointToScreen(dgrProperties.Location); int x = pointToScreen.X + dgrProperties.Columns[0].Width; int y = pointToScreen.Y + dgrProperties.ColumnHeadersHeight + dgrProperties.Rows[e.RowIndex].Height * (e.RowIndex + 1); featuresForm.Location = new Point(x, y); if (featuresForm.ShowDialog() == DialogResult.OK) { FeatureProperty feature = featuresForm.SelectedProperty; if (feature != null && selectedEnvVariable != null) { dgrProperties[e.ColumnIndex, e.RowIndex].Value = feature.Name; selectedEnvVariable.Feature = feature; } } } else if (e.ColumnIndex == 1 && e.RowIndex >= 0) { dgrProperties.BeginEdit(true); Type type = dgrProperties[e.ColumnIndex, e.RowIndex].GetType(); if (type == typeof(DataGridViewComboBoxCell)) { DataGridViewComboBoxEditingControl comboboxEdit = (DataGridViewComboBoxEditingControl)dgrProperties.EditingControl; comboboxEdit.DroppedDown = true; } } }
/// <summary> /// 表示されているコントロールがDataGridViewComboBoxEditingControlなら /// SelectIndexChangedイベントを登録する /// 入力制限をするため、 /// 表示されているコントロールがDataGridViewTextBoxEditingControlなら /// KeyPressイベントを登録する /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvItem_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //表示されているコントロールがDataGridViewComboBoxEditingControlなら //SelectIndexChangedイベントを登録する if (e.Control is DataGridViewComboBoxEditingControl) { DataGridView dgv = (DataGridView)sender; //該当する列か調べる if (dgv.CurrentCell.OwningColumn.Name == "lineWidthCombo") { //編集のために表示されているコントロールを取得 this.dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control; //SelectedIndexChangedイベントハンドラを追加 this.dataGridViewComboBox.SelectedIndexChanged += new EventHandler(dataGridViewComboBox_SelectedIndexChanged); } } //表示されているコントロールがDataGridViewTextBoxEditingControlなら //KeyPressイベントを登録する if (e.Control is DataGridViewTextBoxEditingControl) { DataGridView dgv = (DataGridView)sender; DataGridViewTextBoxEditingControl tb = (DataGridViewTextBoxEditingControl)e.Control; tb.KeyPress -= new KeyPressEventHandler(dataGridViewTextBox_KeyPress); tb.ImeMode = ImeMode.On; if (dgv.CurrentCell.OwningColumn.Name == "YAxisMin" || dgv.CurrentCell.OwningColumn.Name == "YAxisMax") // 数字入力制限の列を指定する { tb.ImeMode = ImeMode.Disable; tb.KeyPress += new KeyPressEventHandler(dataGridViewTextBox_KeyPress); } } }
/// <summary> /// Ensures that only a single click is required to drop down a combo box /// </summary> /// <param name="e">The event arguments</param> protected override void OnCellMouseUp(DataGridViewCellMouseEventArgs e) { base.OnCellMouseUp(e); if (mbSingleClickComboBoxes && e.ColumnIndex >= 0 && e.RowIndex >= 0) { DataGridView ldbgDataGrid = this; DataGridViewColumn lcColumn = ldbgDataGrid.Columns[e.ColumnIndex]; if (lcColumn is DataGridViewComboBoxColumn && ldbgDataGrid != null) { DataGridViewComboBoxCell lcCell = (DataGridViewComboBoxCell)ldbgDataGrid[e.ColumnIndex, e.RowIndex]; if (lcCell != null) { ldbgDataGrid.CurrentCell = lcCell; ldbgDataGrid.BeginEdit(true); DataGridViewComboBoxEditingControl lcEditingControl = (DataGridViewComboBoxEditingControl)ldbgDataGrid.EditingControl; if (lcEditingControl != null) { lcEditingControl.DroppedDown = true; } } } } }
private void DataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dataGridView = (DataGridView)sender; int currentColumn = dataGridView.CurrentCell.ColumnIndex; int currentRow = dataGridView.CurrentCell.RowIndex; if (dataGridView.CurrentCell.ColumnIndex == 2 && e.Control is DataGridViewComboBoxEditingControl) { DataGridViewComboBoxEditingControl comboBox = (DataGridViewComboBoxEditingControl)e.Control; comboBox.DropDownStyle = ComboBoxStyle.DropDown; // Fill the combobox dropdown list with possible values comboBox.Items.Clear(); for (int i = 0; i < 100; i++) { comboBox.Items.Add("Some Value " + i); } // Select current value comboBox.SelectedIndex = comboBox.FindStringExact((string)dataGridView[currentColumn, currentRow].Value); } // Handle the button click if (e.Control is ComboBoxWithButtonEditingControl) { ComboBoxWithButtonEditingControl twb = (ComboBoxWithButtonEditingControl)e.Control; twb.ButtonClicked -= EditingControlButtonClickedEventHandler; // remove the handler added in previous event occurrence twb.ButtonClicked += EditingControlButtonClickedEventHandler; } }
private void columnGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { Type t = e.Control.GetType(); if (t == typeof(DataGridViewComboBoxEditingControl)) { DataGridViewComboBoxEditingControl ec = e.Control as DataGridViewComboBoxEditingControl; ec.DropDownStyle = ComboBoxStyle.DropDown; columnGrid.NotifyCurrentCellDirty(true); ec.Items.Clear(); foreach (string s in dataTypes) { ec.Items.Add(s); } if (tableNode.Table.Columns.Count > columnGrid.CurrentRow.Index) { Column c = tableNode.Table.Columns[columnGrid.CurrentRow.Index]; AdjustComboBox(ec, c.DataType); } ec.TextChanged += new EventHandler(tbDataType_TextChanged); } else if (t == typeof(DataGridViewTextBoxEditingControl)) { DataGridViewTextBoxEditingControl tec = e.Control as DataGridViewTextBoxEditingControl; tec.Multiline = true; tec.Dock = DockStyle.Fill; tec.BorderStyle = BorderStyle.Fixed3D; tec.TextChanged += new EventHandler(tbColumnName_TextChanged); } }
private void DataControls_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Id"); dt.Columns.Add("Desc"); for (int i = 0; i < 20; i++) { DataRow dr = dt.NewRow(); dr[0] = "Jack" + i.ToString(); dr[1] = i * 10; dr[2] = "I like" + i.ToString(); dt.Rows.Add(dr); } //this.dataGridView2.DataSource = dt; bindingSource1.DataSource = dt; dataGridView2.DataSource = bindingSource1; bindingNavigator1.BindingSource = bindingSource1; dataGridView1.Rows[0].Cells[0].Value = "Rose"; dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0]; dataGridView1.BeginEdit(false); DataGridViewComboBoxEditingControl cbox = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl; if (cbox != null) { cbox.DroppedDown = true; } }
void treeGridViewTags_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridViewComboBoxEditingControl column = e.Control as DataGridViewComboBoxEditingControl; column.DropDownStyle = ComboBoxStyle.DropDown; _OldValue = column.Text; }
void comboBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { DataGridViewComboBoxEditingControl currentBox = (DataGridViewComboBoxEditingControl)sender; string value = currentBox.Text.Trim(); if (value == string.Empty) { return; } if (!HostsDal.RegIp.IsMatch(value)) { // 目前仅ip列在用,所以这里强加了,在外面用不生效 // var ipcell = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[COL_IP]; // ipcell.Items.Remove(val); MessageBox.Show("ip:" + value + " 配置错误"); e.Cancel = true; return; } DataGridView grid = currentBox.EditingControlDataGridView; // 如果列表不存在,加入列表 if (currentBox.Items.IndexOf(value) == -1) { // Must add to both the current combobox as well as the template, to avoid duplicate entries //DataGridViewComboBoxColumn cboCol = (DataGridViewComboBoxColumn)grid.Columns[grid.CurrentCell.ColumnIndex]; //cboCol.Items.Add(value); currentBox.Items.Add(value); grid.CurrentCell.Value = value; } }
private void datagridShaderLinks_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridViewComboBoxEditingControl control = e.Control as DataGridViewComboBoxEditingControl; DataGridViewCell cell = datagridShaderLinks.CurrentCell; string strValue = ""; if (cell.Value != null) { strValue = cell.Value.ToString(); } List <object> aryObjsToRemove = new List <object>(); if (control != null) { foreach (object itmItr in control.Items) { if (strValue != itmItr.ToString()) { clsShader shd = Program.Shaders.Find(itm => itm.ToString() == itmItr.ToString()) as clsShader; if (shd != null) { aryObjsToRemove.Add(itmItr); } } } foreach (object itm in aryObjsToRemove) { control.Items.Remove(itm); } } }
private void editingcombo_SelectedIndexChanged(object sender, EventArgs e) { try { DataGridViewComboBoxEditingControl boxEditingControl = (DataGridViewComboBoxEditingControl)sender; DataGridView controlDataGridView = boxEditingControl.EditingControlDataGridView; DataRowView dataRowView = boxEditingControl.SelectedItem as DataRowView; if (controlDataGridView.CurrentCell.ColumnIndex == 2 && boxEditingControl.Text != "") { this.ledger.particulars = boxEditingControl.Text; DataGridViewComboBoxCell viewComboBoxCell = (DataGridViewComboBoxCell)controlDataGridView["referenceinvo", controlDataGridView.CurrentCell.RowIndex]; viewComboBoxCell.DataSource = (object)this.ledger.GetInv(); viewComboBoxCell.DisplayMember = "voucherno"; } else { if (controlDataGridView.CurrentCell.ColumnIndex != 3 || dataRowView == null) { return; } this.ledger.voucherno = dataRowView.Row["voucherno"].ToString(); double num = Convert.ToDouble(this.ledger.GetParticularsBalance()); this.grdVoucher.Rows[controlDataGridView.CurrentCell.RowIndex].Cells["oldbalance"].Value = (object)Math.Abs(num).ToString(); } } catch (Exception) { } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } if (dataGridView1.Columns[e.ColumnIndex].GetType().Equals(typeof(DataGridViewComboBoxColumn))) { if (e.ColumnIndex == Column_dvunit.Index) { string dv = Convert.ToString(dataGridView1[Column_dv.Index, dataGridView1.CurrentRow.Index].Value); if (dv != "Dmax" && dv != "Dmean" && dv != "Dmin") { dataGridView1.BeginEdit(true); DataGridViewComboBoxEditingControl edt = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl; edt.DroppedDown = true; } } else { dataGridView1.BeginEdit(true); DataGridViewComboBoxEditingControl edt = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl; edt.DroppedDown = true; } } }
/// <summary> /// Sets the Recruitment Model of the current index of the multi-recruitment array based off from the /// current selected cell value of dataGridComboBoxRecruitModel. /// </summary> /// <param name="currentModel">Index of the recruitment collection array</param> /// <param name="modelCbx">The DataGridViewComboBoxCell object that is being selected by the user</param> private void OnSelectingRecruitModel(int currentModel, DataGridViewComboBoxEditingControl modelCbx) { object kvpKey; var selectedRecruit = modelCbx.SelectedItem; if (selectedRecruit != null) { Type typeSelectedRecruit = selectedRecruit.GetType(); if (typeSelectedRecruit.IsGenericType) { Type baseTypeSelectedRecruit = typeSelectedRecruit.GetGenericTypeDefinition(); if (baseTypeSelectedRecruit == typeof(KeyValuePair <,>)) { Type[] argTypes = baseTypeSelectedRecruit.GetGenericArguments(); kvpKey = typeSelectedRecruit.GetProperty("Key").GetValue(selectedRecruit, null); this.recruitModelSelection[currentModel] = Convert.ToInt32(kvpKey); int selectedModelNum = Convert.ToInt32(kvpKey); if (this.collectionAgeproRecruitmentModels[currentModel] != null) { this.collectionAgeproRecruitmentModels[currentModel] = AgeproRecruitment.GetNewRecruitModel(selectedModelNum); } } } } }
void cbx_Validating(object sender, CancelEventArgs e) { DataGridViewComboBoxEditingControl cbx = sender as DataGridViewComboBoxEditingControl; DataGridView grid = cbx.EditingControlDataGridView; object value = cbx.Text; // Add value to list if not there if (cbx.Items.IndexOf(value) == -1) { DataGridViewComboBoxCell cboCol = (DataGridViewComboBoxCell)grid.CurrentCell; // Must add to both the current combobox as well as the template, to avoid duplicate entries... cbx.Items.Add(value); cboCol.Items.Add(value); grid.CurrentCell.Value = value; } else { //cbx.SelectedIndex = } } //-----------------------------------------------------------------------------------------
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = 0; int rowSelectedIndex = 0; string selectedProductID = ""; double hpp = 0; DataGridViewComboBoxEditingControl dataGridViewComboBoxEditingControl = sender as DataGridViewComboBoxEditingControl; selectedIndex = dataGridViewComboBoxEditingControl.SelectedIndex; rowSelectedIndex = dataProdukDataGridView.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dataProdukDataGridView.Rows[rowSelectedIndex]; DataGridViewComboBoxCell productIDComboCell = (DataGridViewComboBoxCell)selectedRow.Cells["productID"]; DataGridViewComboBoxCell productNameComboCell = (DataGridViewComboBoxCell)selectedRow.Cells["productName"]; selectedProductID = productIDComboCell.Items[selectedIndex].ToString(); productIDComboCell.Value = productIDComboCell.Items[selectedIndex]; productNameComboCell.Value = productNameComboCell.Items[selectedIndex]; hpp = getProductPriceValue(selectedProductID); selectedRow.Cells["productPrice"].Value = hpp; if (null == selectedRow.Cells["qty"].Value) { selectedRow.Cells["qty"].Value = 0; } }
private void cboColumn_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Down && e.Control) { DataGridViewComboBoxEditingControl cbo = sender as DataGridViewComboBoxEditingControl; cbo.DroppedDown = true; } }
/// <summary> /// We need to trap the EditingControlShowing event so that we can tweak all combo box /// cells to allow the user to edit the contents. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void OnEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (this.Grid.CurrentCell is DataGridViewComboBoxCell) { DataGridViewComboBoxEditingControl combo = (DataGridViewComboBoxEditingControl)this.Grid.EditingControl; combo.DropDownStyle = ComboBoxStyle.DropDown; } }
private void ComboBoxCell_DropDown(object sender, EventArgs e) { // When the drop down list appears, change the DisplayMember property of the ComboBox // to 'TypeAndDescription' to show the description DataGridViewComboBoxEditingControl cmbBx = sender as DataGridViewComboBoxEditingControl; //if (cmbBx != null) // cmbBx.DisplayMember = "TypeAndDescription"; }
private void ComboBoxCell_DropDownClosed(object sender, EventArgs e) { // When the drop down list is closed, change the DisplayMember property of the ComboBox // back to 'Type' to hide the description DataGridViewComboBoxEditingControl cmbBx = sender as DataGridViewComboBoxEditingControl; //if (cmbBx != null) // cmbBx.DisplayMember = "Type"; }
void tblwkladderDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl)) { DataGridViewComboBoxEditingControl cbo = e.Control as DataGridViewComboBoxEditingControl; cbo.DropDownStyle = ComboBoxStyle.DropDown; } }
private void dgCanLamSang_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl)) { DataGridViewComboBoxEditingControl cbo = e.Control as DataGridViewComboBoxEditingControl; cbo.DropDownStyle = ComboBoxStyle.DropDown; cbo.AutoCompleteMode = AutoCompleteMode.Suggest; } }
/// <summary> /// SelectedIndexChangedイベントハンドラを削除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvItem_CellEndEdit(object sender, DataGridViewCellEventArgs e) { // SelectedIndexChangedイベントハンドラを削除 if (this.dataGridViewComboBox != null) { this.dataGridViewComboBox.SelectedIndexChanged -= new EventHandler(dataGridViewComboBox_SelectedIndexChanged); this.dataGridViewComboBox = null; } }
//string m_CellData = string.Empty; #endregion Member Variables #region Constructor #endregion Constructor #region Override methods /// <summary> /// Initialize Editing Control, control type is AIDataGridViewDateTimePickerEditingControl. /// </summary> /// <param name="rowIndex"></param> /// <param name="initialFormattedValue"></param> /// <param name="dataGridViewCellStyle"></param> public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { // Set the value of the editing control to the current cell value. try { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); string typeOfValue = DataGridView.Rows[rowIndex].Cells[2].Value.ToString(); if (typeOfValue == typeof(DateTime).ToString()) { TreeGridViewDateTimePickerEditingControl ctl = DataGridView.EditingControl as TreeGridViewDateTimePickerEditingControl; if (Value != null && Value != OwningColumn.DefaultCellStyle) { try { ctl.Value = Convert.ToDateTime(Value.ToString()); } catch (Exception ex) { ex.ToString(); ctl.Value = DateTime.Now; } } } else if (typeOfValue == typeof(Boolean).ToString()) { DataGridViewComboBoxEditingControl ctl = DataGridView.EditingControl as DataGridViewComboBoxEditingControl; //setting combox style ctl.DropDownStyle = ComboBoxStyle.DropDownList; ctl.FlatStyle = FlatStyle.Popup; FillBoolColumnValue(ctl); if (Value != null && Value != OwningColumn.DefaultCellStyle) { try { ctl.EditingControlFormattedValue = Value.ToString(); } catch (Exception ex) { ex.ToString(); ctl.SelectedItem = ctl.Items[0].ToString(); } } ctl.Width = OwningColumn.Width; } } catch (Exception oEx) { string str = oEx.Message; } }
void grdColumns_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is DataGridViewComboBoxEditingControl) { DataGridViewComboBoxEditingControl cb = e.Control as DataGridViewComboBoxEditingControl; ColumnValidation cv = _colValsByName[(string)grdColumns.CurrentRow.Cells[0].Value]; cb.DataSource = cv.ReferenceableColumns; } }
private void dgv_TColumns_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl)) { DataGridViewComboBoxEditingControl combo = e.Control as DataGridViewComboBoxEditingControl; combo.DropDownStyle = ComboBoxStyle.DropDown; combo.TextChanged += new EventHandler(combo_TextChanged); } }