Select Items from Data Grid in C#.NET
Kettic DataGridView provides users of GridView Control the selection functionality to select one or more rows or cells from the shown data. This selection features support multiple selection functionality and rows and cells selection in C# code. For example, the GridView component supports a single row selection, multiple rows selection, a single cell selection, as well as multiple cells selection. UI designers can easily customize the GridView selection in C# code in their .NET projects.
How Select Grid Row in C#
To select rows from data grid, we need enable the selection to DataGrid. The default selection setting of Kettic GridView allows users select one row from the data grid. The C# code below demonstrates the default setting of this property.
How to Select Grid Cell in C#
To select cells from data grid, we can change the value of the SelectMode property to SelectCell from the GridViewSelectMode enumeration. The C# code below shows how to achieve this.
How to Select Items in Data Grid
When we selected the items like rows and cells from data grid, the item will be added to the SelectedGridRows and SelectedGridCells collections respectively. The C# code below shows how to access the collections of the cells and rows:
Selection Events for GridView
The Kettic GridView provides two selection C# events available, the ChangedSelection and ChangedCurrentCell. When the ChangedCurrentCell event is fired, the ChangedSelection event will be fired. CurrentRow and CurrentCell of GridView
The current row and current cell are determined by the item that we selected in basic selection mode. When we select a row or cell in data grid, the GridView will automatically enable the IsCurrent property and the CurrentRow or CurrentCell property will hold an instance of the row or cell. The C# code below shows that how to access the CurrentRow, CurrentCell, and the IsCurrent properties.
|
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 - RowGridView - CellsGridView - EditorsGridView - Context MenuGridView - Populating with DataGridView - Hierarchical GridData Binding AutomaticallyData Binding ProgrammaticallyXML Data SourceResize Child GridVieInfoOne to Many RelationsExpand RowsGridView - SelectionBasic SelectionMultiple SelectionProgrammatical Rows & Cells Selection GridView - ScrollingGridView - SortingSet ProgrammaticallySorting ExpressionsGridView - 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 |