Class GridComboBoxColumn
Represents a column that used to display the SfComboBox as the edit element.
Inheritance
Inherited Members
Namespace: Syncfusion.WinForms.DataGrid
Assembly: Syncfusion.SfDataGrid.WinForms.dll
Syntax
public class GridComboBoxColumn : GridColumn, IDisposable, IFilterDefinition
Constructors
GridComboBoxColumn()
Initializes a new instance of the GridComboBoxColumn class.
Declaration
public GridComboBoxColumn()
Properties
AllowNull
Gets or sets a value indicating whether the null values are allowed in the column or not.
Declaration
[Cloneable(true)]
public bool AllowNull { get; set; }
Property Value
Type |
---|
System.Boolean |
AutoCompleteMode
Gets or sets the AutoCompleteMode of the ComboBox.
Declaration
public AutoCompleteMode AutoCompleteMode { get; set; }
Property Value
Type |
---|
System.Windows.Forms.AutoCompleteMode |
AutoSuggestDelay
Gets or sets a value indicating the delay for auto suggestion.
Declaration
public int AutoSuggestDelay { get; set; }
Property Value
Type |
---|
System.Int32 |
AutoSuggestMode
Gets or sets a valuee indicating the AutoSuggestMode of ComboBox.
Declaration
public AutoCompleteSuggestMode AutoSuggestMode { get; set; }
Property Value
Type |
---|
AutoCompleteSuggestMode |
DataSource
Gets or sets the data source of the ComboBox.
Declaration
public object DataSource { get; set; }
Property Value
Type |
---|
System.Object |
Examples
The following example shows how to set the DataSource for combo box column.
// Declare the SfDataGrid control.
private Syncfusion.WinForms.DataGrid.SfDataGrid sfDataGrid;
// Initialize the SfDataGrid.
private void InitializeDataGrid()
{
// Create a new SfDataGrid control and set the location and size.
this.sfDataGrid = new Syncfusion.WinForms.DataGrid.SfDataGrid();
this.sfDataGrid.Location = new System.Drawing.Point(10, 5);
this.sfDataGrid.Size = new System.Drawing.Size(750, 450);
// Create a new GridComboBoxColumn and set the DataSource for combo box column.
GridComboBoxColumn gridComboBoxColumn = new GridComboBoxColumn();
gridComboBoxColumn.MappingName = "ShipCityID";
gridComboBoxColumn.HeaderText = "Ship City";
gridComboBoxColumn.ValueMember = "ShipCityID";
gridComboBoxColumn.DisplayMember = "ShipCityName";
gridComboBoxColumn.DropDownStyle = DropDownStyle.DropDownList;
gridComboBoxColumn.DataSource = orderInfo.ShipCityDetails;
// Added the columns to the SfDataGrid.
this.sfDataGrid.Columns.Add(gridComboBoxColumn);
this.sfDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "Order ID" });
this.sfDataGrid.Columns.Add(new GridTextColumn() { MappingName = "CustomerID", HeaderText = "Customer ID" });
this.sfDataGrid.Columns.Add(new GridDateTimeColumn() { MappingName = "OrderDate", HeaderText = "Order Date" });
// Set the tab index and add the SfDataGrid to the form.
this.sfDataGrid.TabIndex = 0;
this.Controls.Add(this.sfDataGrid);
}
DisplayMember
Gets or sets the DisplayMember of the ComboBox.
Declaration
public string DisplayMember { get; set; }
Property Value
Type |
---|
System.String |
DropDownStyle
Gets or sets a value indicating whether the ComboBox is editable or not.
Declaration
public DropDownStyle DropDownStyle { get; set; }
Property Value
Type |
---|
DropDownStyle |
IDataSourceSelector
Gets or sets the DataSource selector for the individual ComboBox cells.
Declaration
public IDataSourceSelector IDataSourceSelector { get; set; }
Property Value
Type |
---|
IDataSourceSelector |
StaysOpenOnEdit
Gets or sets a value indicating whether the DropDown should open on editing.
Declaration
public bool StaysOpenOnEdit { get; set; }
Property Value
Type |
---|
System.Boolean |
ValueMember
Gets or sets the ValueMember of the ComboBox.
Declaration
public string ValueMember { get; set; }
Property Value
Type |
---|
System.String |
Methods
GetDisplayValue(Object, String, Object)
Gets the display value of the ComboBox.
Declaration
public static object GetDisplayValue(object dataSource, string displayMember, object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | dataSource | The dataSource of the combo box. |
System.String | displayMember | The display member of combo box. |
System.Object | item | The row item object. |
Returns
Type | Description |
---|---|
System.Object | Returns the display value of the combo box. |
GetFormattedValue(Object, Object)
Overridden to get the formatted display text.
Declaration
protected override object GetFormattedValue(object record, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | record | A record value. |
System.Object | value | Display text value. |
Returns
Type | Description |
---|---|
System.Object | Returns the formatted value. |
Overrides
GetItemValue(Object, String, Object)
Gets the value of the combo box.
Declaration
public static object GetItemValue(object dataSource, string valueMember, object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | dataSource | The DataSource. |
System.String | valueMember | The value member. |
System.Object | item | The row object. |
Returns
Type | Description |
---|---|
System.Object | Returns the value of the combo box. |