如何在AdvStringGrid中进行反向选择?

时间:2011-10-08 15:26:11

标签: delphi tms

如何在AdvStringGrid(TMS)中进行反向选择?

1 个答案:

答案 0 :(得分:3)

假设NGLN是正确的,您需要在Grid.MouseActions中设置正确的Disjunct ... Select选项以选择您允许的选择类型,然后您可以调用此过程:

PROCEDURE InvertSelection(Grid : TAdvStringGrid);
  VAR
    C,R : Cardinal;

  BEGIN
    IF Grid.MouseActions.DisjunctCellSelect THEN
      FOR R:=Grid.FixedRows TO PRED(Grid.RowCount) DO FOR C:=Grid.FixedCols TO PRED(Grid.ColCount) DO Grid.SelectedCells[C,R]:=NOT Grid.SelectedCells[C,R]
    ELSE IF Grid.MouseActions.DisjunctRowSelect THEN
      FOR R:=Grid.FixedRows TO PRED(Grid.RowCount) DO Grid.RowSelect[R]:=NOT Grid.RowSelect[R]
    ELSE IF Grid.MouseActions.DisjunctColSelect THEN
      FOR C:=Grid.FixedCols TO PRED(Grid.ColCount) DO Grid.ColSelect[C]:=NOT Grid.ColSelect[C]
  END;

这将选择所有未选择的行/列/单元格,反之亦然。