无论如何要确定当前在 multi-select 中选择了哪些行TStringGrid
,或者TCustomGrid
就此而言。一个属性将是理想的。
我知道在事件中gdSelected
设置了属性,DrawCell
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
我可以检查AState
,gdSelected
并在某处的数组中跟踪它,但这似乎很笨拙。
无论如何要确定当前在 multi-select 中选择了哪些行TStringGrid
,或者TCustomGrid
就此而言。一个属性将是理想的。
我知道在事件中gdSelected
设置了属性,DrawCell
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
我可以检查AState
,gdSelected
并在某处的数组中跟踪它,但这似乎很笨拙。
我猜您说的是范围选择字符串网格,即带有goRangeSelect
in的字符串网格Options
。然后,您可以使用该 Selection
属性。这(本质上)是一个TRect
,您可以在其中找到范围选择中的左上角和右下角单元格。
哦,我StringGrid.Selection.BottomRight.Y
用来确定行和StringGrid.Selection.BottomRight.X
列。
使用字符串网格选择属性StringGrid.Selection.top
将为您提供顶部选定的行,StringGrid.Selection.bottom
将为您提供结束选定的行,选择停止的位置。
例子:
如果您在字符串网格中从第 3 行到第 6 行进行选择,StringGrid.Selection.top
则将给您 3 作为输出值StringGrid.Selection.bottom
,将给您 6 作为输出值,其余值可以通过从上到下迭代获得。