![]() ![]() | ||
We've already put the data grid control to work in the previous chapter, and in the DataBinding example in this chapter. This control displays a data table all at once in a scrollable grid format and is supported by the DataGrid class. Here is the inheritance hierarchy of this class:
Object MarshalByRefObject Component Control DataGrid
You also can display hierarchical datasets in data grids. In a hierarchical dataset, fields themselves can display Web-like links to child tables. You can click a link to navigate to the child table. When a child table is displayed, a back button appears in the caption that can be clicked to navigate back to the parent table.
You can find the more notable public properties of DataGrid objects in Table 21.6, their more notable methods in Table 21.7, and the more notable events in Table 21.8. Note that as with other Windows controls, I am not listing the notable properties, methods, and events ListBox inherits from the Control class, such as the Click event—you can see all that in Chapter 5, Tables 5.1, 5.2, and 5.3.
Method |
Means |
---|---|
BeginEdit |
Allows editing. |
Collapse |
Collapses child table relations. |
EndEdit |
Ends editing operations. |
Expand |
Displays child relations. |
GetCellBounds |
Gets the Rectangle object that specifies a cell. |
GetCurrentCellBounds |
Gets a Rectangle object that specifies the selected cell. |
HitTest |
Coordinates mouse position with points in the data grid. |
IsExpanded |
Gets whether a row is expanded or collapsed. |
IsSelected |
Gets whether a row is selected. |
NavigateBack |
Navigates to the previous table that was shown in the grid. |
NavigateTo |
Navigates to a specific table. |
Select |
Makes a selection. |
SetDataBinding |
Sets both the DataSource and DataMember properties. Used at run time. |
UnSelect |
Unselects a row. |
Event |
Means |
---|---|
AllowNavigationChanged |
Occurs when the AllowNavigation property changes. |
CurrentCellChanged |
Occurs when the CurrentCell property changes. |
DataSourceChanged |
Occurs when the DataSource property value changes. |
FlatModeChanged |
Occurs when the FlatMode changes. |
Navigate |
Occurs when the user navigates to a new table. |
ParentRowsVisibleChanged |
Occurs when the ParentRowsVisible property value changes. |
ReadOnlyChanged |
Occurs when the ReadOnly property value changes. |
Scroll |
Occurs when the data grid is scrolled. |
![]() ![]() | ||