Gets or sets the data source whose data contains the possible selections shown in the drop-down list.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
abstract DataSource : Object with get, set override DataSource : Object with get, set
Typically this property will be set for an entire column of cells through the DataGridViewComboBoxColumn.DataSource property.
If possible, set to a source containing only the possible selections, like a column of selections. Then the DisplayMember property doesn't need to be set. But if the source is more complicated, set DisplayMember to the name of the property or column from which to retrieve possible selections.
Changing the property causes the cell to reinitialize its Items collection and redraw itself.
When you change the value of the property, the control attempts to use the ValueMember and DisplayMember property values with the new data source, and sets each property to a null reference (Nothing in Visual Basic) if its value cannot be found. Any exception that occurs during this process is ignored unless it is one of the following critical exceptions: NullReferenceException, StackOverflowException, OutOfMemoryException, ThreadAbortException, ExecutionEngineException, IndexOutOfRangeException, or AccessViolationException.
When the is set, the DataGridViewComboBoxCell attaches to the Disposed event of the data source. When the DataGridViewComboBoxCell is detached from the DataGridView, the resource is not immediately released. The DataGridViewComboBoxCell resource is released when the attached data source is disposed. To release the resource for garbage collection immediately, set the property to a null reference (Nothing in Visual Basic).
The following code example demonstrates the use of the DataGridViewComboBoxColumn.DataSource property, which is similar to this property. This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.