dotnetmonitor.com

 
Index
Previous
Next

 

The DataGridView control uses several column types to display its information and enable users to modify or add information.

 

When you bind a DataGridView control and set the AutoGenerateColumns property to true, columns are automatically generated using default column types appropriate for the data types contained in the bound data source.

 

You can also create instances of any of the column classes yourself and add them to the collection returned by the Columns property. You can create these instances for use as unbound columns, or you can manually bind them. Manually bound columns are useful, for example, when you want to replace an automatically generated column of one type with a column of another type.

 

The following table describes the various column classes available for use in the DataGridView control:

Class

Description

DataGridViewTextBoxColumn

Used with text-based values. Generated automatically when binding to numbers and strings.

DataGridViewCheckBoxColumn

Used with Boolean and CheckState values. Generated automatically when binding to values of these types.

DataGridViewImageColumn

Used to display images. Generated automatically when binding to byte arrays, Image objects, or Icon objects.

DataGridViewButtonColumn

Used to display buttons in cells. Not automatically generated when binding. Typically used as unbound columns.

DataGridViewComboBoxColumn

Used to display drop-down lists in cells. Not automatically generated when binding. Typically data-bound manually.

DataGridViewLinkColumn

Used to display links in cells. Not automatically generated when binding. Typically data-bound manually.

Your custom column type

You can create your own column class by inheriting the DataGridViewColumn class or any of its derived classes to provide custom appearance, behavior, or hosted controls. For more information, see How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance

What is the DataGridView
Differences between the DataGridView and DataGrid controls
Highlight of features
Structure of DGV
Architecture Elements
Cells and Bands