This documentation is archived and is not being maintained.

DataGridViewComboBoxColumn.DataSource Property

Gets or sets the data source that populates the selections for the combo boxes.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member DataSource : Object with get, set

Property Value

Type: System.Object
An object that represents a data source. The default is a null reference (Nothing in Visual Basic).


The value of the CellTemplate property is a null reference (Nothing in Visual Basic).

The DataSource or Items properties specify where to retrieve the selection data shown in the combo box drop-down list. When using the DataSource property, if the data must be drawn from a nondefault property or column, then the DisplayMember property must be set to the name of the nondefault property or column.

If the DataSource property is set to a string array, then ValueMember and DisplayMember do not need to be set because each string in the array will be used for both value and display.

Getting or setting this property gets or sets the DataSource property of the object returned by the CellTemplate property. Setting this property also sets the DataSource property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value.

The following code example demonstrates how to use a DataGridViewComboBoxColumn to aid in entering data into the TitleOfCourtesy column. The DataSource property is used to populate the combo box with a selection of titles. This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.