How to: Change the Type of a Windows Forms DataGridView Column Using the Designer
Sometimes you will want to change the type of a column that has already been added to a Windows Forms DataGridView control. For example, you may want to modify the types of some of the columns that are generated automatically when you bind the control to a data source. This is useful when the table you display has columns containing foreign keys to rows in a related table. In this case, you may want to replace the text box columns that display these foreign keys with combo box columns that display more meaningful values from the related table.
The following procedure requires a Windows Application project with a form containing a DataGridView control. For information about setting up such a project, see How to: Create a Windows Application Project and How to: Add Controls to Windows Forms.
Note
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.
To change the type of a column using the designer
Click the smart tag glyph () on the upper-right corner of the DataGridView control, and then select Edit Columns.
Select a column from the Selected Columns list.
In the Column Properties grid, set the ColumnType property to the new column type.
Note
The ColumnType property is a design-time-only property that indicates the class representing the column type. It is not an actual property defined in a column class.
See Also
Tasks
How to: Create a Windows Application Project
How to: Add Controls to Windows Forms