Name

DataGrid

Synopsis

This class is the successor to the old unmanaged FlexGrid control, and has considerably more power, fully supporting complex data-binding scenarios.

A grid offers a two dimensional view of the rows and columns on a data source. The data source itself may consist of several related tables, each with different rows and columns, so the grid offers support for drilling down through these relations, updating the display to reflect the current view on the data.

There are a variety of basic areas in the grid whose appearance you can change. You can show and hide a caption (title) area with the CaptionVisible property. You can set the CaptionFont, CaptionForeColor, and CaptionBackColor, as well as the CaptionText.

If a particular row in the data source has been defined to have relations to another table, the grid displays a hyperlink for you to click on to follow that relation. You can set its LinkColor and LinkHoverColor. This drill-down behavior is enabled and disabled with the AllowNavigation property. When you have drilled down into a table, a line is added to display the parent rows through which you have navigated. You can set the ParentRowsBackColor, ParentRowsForeColor, and visibility (ParentRowsVisible). In addition, you can set the ParentRowsLabelStyle to display either the parent ColumnName, TableName, or both. You can also NavigateTo() a particular row and relation, or NavigateBack() to the parent of the current view.

Then, there are the column headers (which ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.