小弟写了一个程序, 里面用到了 StringGrid控件.我为其关联了一个PopMenu.PopMenu里面的菜单项是对StringGrid选定的那一行进行操作的. 如果我要对StringGrid当中某一行进行操作,那么首先需要鼠标左键选取那一行,然后再点击鼠标右键弹出菜单来进行操作. 而如果我直接使用 鼠标右键在我想要操作的那一行上点击,那么StringGrid的选定行(Row属性)仍然是原来的行,而不是我想要操作的这一行,请问各位有什么办法解决这个问题吗?
调试欢乐多
TStringGridEx = class(TStringGrid);procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
TStringGridEx(Sender).OnMouseDown := nil;
TStringGridEx(Sender).MouseDown(mbLeft, Shift, X, Y);
TStringGridEx(Sender).OnMouseDown := StringGrid1MouseDown;
end;
end;
StringGrid.MouseToCell函数