DataGridViewComboBoxEditingControl Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class DataGridViewComboBoxEditingControl Inherits ComboBox Implements IDataGridViewEditingControl 'Usage Dim instance As DataGridViewComboBoxEditingControl
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class DataGridViewComboBoxEditingControl extends ComboBox implements IDataGridViewEditingControl
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class DataGridViewComboBoxEditingControl extends ComboBox implements IDataGridViewEditingControl
The DataGridViewComboBoxEditingControl class is a specialized type of ComboBox that implements the IDataGridViewEditingControl interface, allowing it to be hosted in a DataGridViewComboBoxCell when the cell is in edit mode. When a DataGridViewComboBoxCell is in edit mode, you can retrieve the DataGridViewComboBoxEditingControl through the EditingControl property of the DataGridView control.
Handle the EditingControlShowing event to perform custom initialization of the editing control when a cell enters edit mode. To customize the display characteristics of the control, set the properties of the object returned by the DataGridViewEditingControlShowingEventArgs.CellStyle property rather than setting the properties of the control returned by the DataGridViewEditingControlShowingEventArgs.Control property.
The following code example demonstrates how to use an DataGridView.EditingControlShowing event handler to add a handler for a DataGridViewComboBoxEditingControl event. In the example, the editing control is cast to a ComboBox to handle the ComboBox.SelectedIndexChanged event.
Private WithEvents dataGridView1 As New DataGridView() Private Sub AddColorColumn() Dim comboBoxColumn As New DataGridViewComboBoxColumn() comboBoxColumn.Items.AddRange( _ Color.Red, Color.Yellow, Color.Green, Color.Blue) comboBoxColumn.ValueType = GetType(Color) dataGridView1.Columns.Add(comboBoxColumn) End Sub Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, _ ByVal e As DataGridViewEditingControlShowingEventArgs) _ Handles dataGridView1.EditingControlShowing Dim comboBox1 As ComboBox = CType(e.Control, ComboBox) AddHandler comboBox1.SelectedIndexChanged, _ New EventHandler(AddressOf ComboBox_SelectedIndexChanged) End Sub Private Sub ComboBox_SelectedIndexChanged( _ ByVal sender As Object, ByVal e As EventArgs) Dim comboBox1 As ComboBox = CType(sender, ComboBox) comboBox1.BackColor = _ CType(CType(sender, ComboBox).SelectedItem, Color) End Sub
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ListControl
System.Windows.Forms.ComboBox
System.Windows.Forms.DataGridViewComboBoxEditingControl
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
DataGridViewComboBoxEditingControl MembersSystem.Windows.Forms Namespace
DataGridView Class
DataGridView.EditingControl Property
DataGridView.EditingControlShowing Event
DataGridViewEditingControlShowingEventArgs.CellStyle
DataGridViewEditingControlShowingEventArgs.Control
ComboBox Class
IDataGridViewEditingControl
DataGridViewComboBoxCell Class
DataGridViewTextBoxEditingControl