Udostępnij za pośrednictwem


How to: Change the Order of Columns in the Windows Forms DataGridView Control Using the Designer

When you bind a Windows Forms DataGridView control to a data source, the display order of the automatically generated columns is dictated by the data source. If this order is not what you prefer, you can change the order of the columns using the designer. You may also want to add unbound columns to the control and change their display order. For information about how to change the column order programmatically, see How to: Change the Order of Columns in the Windows Forms DataGridView Control.

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 New Windows Forms 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 Working with Settings

To change the column order using the designer

  1. Click the smart tag glyph (Smart Tag Glyph) on the upper-right corner of the DataGridView control, and then select Edit Columns.

  2. Select a column from the Selected Columns list.

  3. Click the up or down arrow to the right of the Selected Columns list until the selected column is in the position you want.

See Also

Tasks

How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer

How to: Create a New Windows Forms Application Project

How to: Add Controls to Windows Forms

Reference

DataGridView