Export (0) Print
Expand All

Default Functionality in the Windows Forms DataGridView Control

The Windows Forms DataGridView control provides users with a significant amount of default functionality.

By default, a DataGridView control:

  • Automatically displays column headers and row headers that remain visible as the table scrolls vertically.

  • Has a row header that contains a selection indicator for the current row.

  • Has a selection rectangle in the first cell.

  • Has columns that can be automatically resized when the user double-clicks the column dividers.

  • Automatically supports visual styles on Windows XP and the Windows Server 2003 family when the EnableVisualStyles method is called from the application's Main method.

Additionally, the contents of a DataGridView control can be edited by default:

  • If the user double-clicks or presses F2 in a cell, the control automatically puts the cell into edit mode and updates the contents of the cell as the user types.

  • If the user scrolls to the end of the grid, the user will see that a row for adding new records is present. When the user clicks this row, a new row is added to the DataGridView control, with default values. When the user presses ESC, this new row disappears.

  • If the user clicks a row header, the whole row is selected.

When you bind a DataGridView control to a data source by setting its DataSource property, the control:

  • Automatically uses the names of the data source's columns as the column header text.

  • Is populated with the contents of the data source. DataGridView columns are automatically created for each column in the data source.

  • Creates a row for each visible row in the table.

  • Automatically sorts the rows based on the underlying data when the user clicks a column header.

Community Additions

ADD
Show:
© 2014 Microsoft