How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer
The Windows Forms DataGridView control must contain columns in order to display data. If you plan to populate the control manually, you must add the columns yourself. Alternately, you can bind the control to a data source, which generates and populates the columns automatically. If the data source contains more columns than you want to display, you can remove the unwanted columns.
The following procedures require 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 add a column using the designer
Click the smart tag glyph () on the upper-right corner of the DataGridView control, and then select Add Column.
In the Add Column dialog box, choose the Databound Column option and select a column from the data source, or choose the Unbound Column option and define the column using the fields provided.
Click the Add button to add the column, causing it to appear in the designer if the existing columns do not already fill the control display area.
Note
You can modify column properties in the Edit Columns dialog box, which you can access from the control's smart tag.
To remove a column using the designer
Choose Edit Columns from the control's smart tag.
Select a column from the Selected Columns list.
Click the Remove button to delete the column, causing it to disappear from the designer.
See Also
Tasks
How to: Create a Windows Application Project
How to: Add Controls to Windows Forms