ComponentOne True DBGrid for WinForms
Run-Time Interaction / Selection, Sorting, and Movement / Selecting a Range of Cells
In This Topic
    Selecting a Range of Cells
    In This Topic

    When it comes to cell selection, True DBGrid for WinForms has multi-select capability enabled at all times, very similar to Microsoft Excel. By clicking on a cell and dragging the mouse, or by using the arrow keys, a range of cells can be selected. In turn, by clicking on a record selector and manipulating the mouse a set of rows can be selected. This range is not restricted to the row or column of the initial cells origin, although non-contiguous cell selection is not supported.

    When a range of cells is selected the grid’s SelRange property becomes True. This will indicate that neither just the SelectedRowCollection nor just the SelectedColumnCollection collections will tell which cells are selected. By evaluating both collections, though, and taking the intersection of the two collections, the selected cell range can be discovered at run time. For instance, if the user clicked on the second row, second column, and dragged the mouse to the fourth row, fourth column, the SelectedRowCollection collection would contain the integers 2, 3, and 4, while the SelectedColumnCollection collection would contain the C1DataColumn objects for columns 2, 3, and 4. From this, it can be discerned at run-time that there is a nine-cell range selected from column 2, row 2, to column 4, row 4.

    See Also