IsCellSelected(这是我的程序里用到的一个方法,可以在鼠标单击的时候来调用,可以快速知道行号
能满足要求了吧,如果能请给我200分,谢谢!
function IsCellSelected(StringGrid : TStringGrid; X, Y : LONGINT): BOOLEAN;
begin
Result := false;
try
if (X >= StringGrid.Selection.Left) and (X <= StringGrid.Selection.Right) and (Y >= StringGrid.Selection.Top) and (Y <= StringGrid.Selection.Bottom)
then
Result := true;
except
end;
end;
例子:
for x:= 1 to stgd_detail.rowcount do
begin
if IsCellSelected(stgd_detail,0,x) then
showmessage(stgd_detail.cells[0,x]);//得到选中行的第0个数据
break;
end;