GrapeCity MultiRow Windows Forms Documentation
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.

Selecting Rows and Cells

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.

Selection of Row and Selection of All Cells in the Row

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.

Using Code

The following code enumerates the row number and index of selected cells.

[VB]

Imports GrapeCity.Win.MultiRow

For Each cell As Cell In GcMultiRow1.SelectedCells
    Console.WriteLine("Selected Cell: {0},{1}", cell.CellIndex, cell.RowIndex)
Next

[CS]

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.

[VB]

Imports GrapeCity.Win.MultiRow

For Each row As Row In GcMultiRow1.SelectedRows
    Console.WriteLine("Selected Row: {0}", row.Index)
Next

[CS]

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.

Using Code

The following code gets only the selected rows from all the rows using the Row.Selected Property (Section.Selected) property.

[VB]

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

[CS]

using GrapeCity.Win.MultiRow;

foreach (Row row in gcMultiRow1.Rows)
{
    if (row.Selected == true)
        Console.WriteLine("Selected Row: {0}", row.Index);
}
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options