MultiRow Windows Forms > Developer's Guide > Using MultiRow > Rows and Cells > Selected Rows and Cells |
The GcMultiRow.SelectedCells property and the GcMultiRow.SelectedRows property can be used to get the selected rows and cells in the GcMultiRow control. Also, the GcMultiRow.AreAllCellsSelected method can be used to determine whether all the cells have been selected. See Selecting Cells using Headers for details on selecting cells using the headers.
Depending on how the selection has been made, the result of selecting a row is different from selecting all the cells in the row. The following figure depicts selecting a row, on the left, and selecting all the cells in the row, on the right.
Whether a row or its cells are selected by clicking the row header depends on the value of the HeaderCell.SelectionMode property. For more information, see Selecting Cells using Headers.
The following code enumerates the row number and index of selected cells.
Imports GrapeCity.Win.MultiRow For Each cell As Cell In GcMultiRow1.SelectedCells Console.WriteLine("Selected Cell: {0},{1}", cell.CellIndex, cell.RowIndex) Next |
using GrapeCity.Win.MultiRow; foreach (Cell cell in gcMultiRow1.SelectedCells) { Console.WriteLine("Selected Cell: {0},{1}", cell.CellIndex, cell.RowIndex); } |
The following code enumerates the index of the selected row.
Imports GrapeCity.Win.MultiRow For Each row As Row In GcMultiRow1.SelectedRows Console.WriteLine("Selected Row: {0}", row.Index) Next |
using GrapeCity.Win.MultiRow; foreach (Row row in gcMultiRow1.SelectedRows) { Console.WriteLine("Selected Row: {0}", row.Index); } |
It is also possible to verify whether a row or cell is selected by looking at the row or cell side.
The following code gets only the selected rows from all the rows using the Row.Selected Property (Section.Selected) property.
Imports GrapeCity.Win.MultiRow For Each row As Row In GcMultiRow1.Rows If row.Selected = True Then Console.WriteLine("Selected Row: {0}", row.Index) End If Next |
using GrapeCity.Win.MultiRow; foreach (Row row in gcMultiRow1.Rows) { if (row.Selected == true) Console.WriteLine("Selected Row: {0}", row.Index); } |