Rows and Child Rows of C# DataGridView
The Kettic DataGridView control provides the collections, Rows and Child Rows, to include data rows. The Rows collections include all data rows of the Kettic GridView control and the operations of selecting, grouping, sorting, filtering, and scrolling, will not change the content or order in which the grid rows objects exist. The ChildRows collection will returns the data rows stands for the Kettic GridView in the order appearing. The operations of grouping, sorting, filtering will change the ChildRows collection each time.
Sample of Rows and ChildRows
We are going through the example below to understand the difference between Rows and ChildRows. In the example below, there is a Kettic DataGridView that has been bound to the data source table. We will add a column representing the indices of the rows of the Rows collection and a column representing the indices of the rows in the context of the ChildRows collection to the GridView. And then execute some data operations, grouping, sorting, and filtering, to shows how the ChildRows collection will be changed.
1. Add two columns to the GirdView control for C# Windows Forms application
2. Fill integers to the two columns according to the rows order in the collections of Rows and the ChildRows. In this step, we will not apply any operations like grouping, sorting, and filtering, so the ChildRows of the GridView will not change anything.
3. In this step, we will perform the data operation to check the changes of the ChildRows. For instance, we can apply the filtering to the Kettic GridView. When the filtering data operation occurs, the FilterChanged event is fired, and in the event handler of the FilterChanged event, the indices will be refilled the two columns. Finally, the indices of the grid rows will not match anymore.
4. In this step, we will perform the sorting data operation to the records from the above step to the column. The SortChanged event is fired and the two custom columns will be refilled by the indices. The result is expected and the rows in the ChildRows are the only rows shown by the GridView and ordered as representing.
5. Finally, we will perform the grouping data operation to the City column. We will fire the GroupChanged event, in which the event handler will be filled by indices to the two columns.
The above C# code has not finished the grouping. Furthermore, we need to modify the body of the SetIDs method as following C# code to get the correct and expected result. |
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlGridView - Get Started in C#GridView - PropertiesGridView - ColumnGridView - RowRow - IterateRow - InsertRow - RemoveRow - Rows & Child RowsRow - Format RowsRow - Pinned RowsRow - Select RowsRow - Conditional Format RowsRow - Selection RectangleRow - Summary RowsRow - Painting RowsGridView - CellsGridView - EditorsGridView - Context MenuGridView - Populating with DataGridView - Hierarchical GridGridView - SelectionGridView - ScrollingGridView - SortingGridView - GroupingGridView - FilteringGridView - Expression EditorInsert/ Update/ Delete RecordsGridView - View DefinitionGridView - Exporting DataStyling and AppearanceGridView - LocalizationSave and Load LayoutGridView - Print SupportWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |