如何实现2个StringGrid的滚动条的同步 如何实现2个StringGrid的滚动条的同步当控制其中一个StringGrid的滚动条时,另一个StringGrid的对应的滚动条也作同步移动。(截获消息?)请问那位高手知道实现的方法啊!!! 谢谢!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 加一个ScrollBar,把StringGrid自己的盖掉,在ScrollBar的Change事件中写 StringGrid1.TopRow :=ScrollBar1.Position ; StringGrid2.TopRow :=ScrollBar1.Position ;OK!测试通过 呵呵,一年前我也问过这个问题,当时我悬赏1000分(那时确实菜,现在看看我的经理也好不到拿去),可是最后有我的项目经理解决了,搞笑。。unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids;type TForm1 = class(TForm) stg1: TStringGrid; stg2: TStringGrid; procedure stg1TopLeftChanged(Sender: TObject); procedure stg2TopLeftChanged(Sender: TObject); procedure stg1Click(Sender: TObject); procedure stg2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.stg1TopLeftChanged(Sender: TObject);begin stg2.LeftCol := stg1.LeftCol; stg2.TopRow := stg1.TopRow;end;procedure TForm1.stg2TopLeftChanged(Sender: TObject);beginstg1.LeftCol := stg2.LeftCol; stg1.TopRow := stg2.TopRow;end;procedure TForm1.stg1Click(Sender: TObject);beginstg2.Row:=stg1.Row;stg2.Col:=stg1.Col;end;procedure TForm1.stg2Click(Sender: TObject);beginstg1.Row:=stg2.Row;stg1.Col:=stg2.Col;end;end.将stringgrid的option中的rowselect设为true,效果很明显。以上是我的经理的解决方法,可行。不过我觉得还是拦截stringgrid的消息,重载WindowProc过程思路比较正统一点 fengsx (fengsx) 你先试试上面的代码,不满意我再用我的思路是试试 SetScrollPos(StringGrid2.Handle,SB_VERT,GetScrollPosStringGrid1.Handle,SB_VERT ),true); 解密,OLLYICE软件 delphi7控件问题 有关快捷方式的问题。 在csdn首页有篇文章提到在Delphi7.0中有Delphi for .NET的预览版,可我安装后没有找到,应该怎样安装呢? 两个不难的问?(急~~~~~) 大家用dephi的什么版本开发?! 北京通审公司招聘delphi程序员 2个DSVideoWindowEx同时连接同一个fitergraph webbrowser,为什么DBGrid无法获得焦点 dbchart如何显示多个字段 treeview中如何多选? ?????WebService如何实现身份验证?
StringGrid2.TopRow :=ScrollBar1.Position ;OK!测试通过
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;type
TForm1 = class(TForm)
stg1: TStringGrid;
stg2: TStringGrid;
procedure stg1TopLeftChanged(Sender: TObject);
procedure stg2TopLeftChanged(Sender: TObject);
procedure stg1Click(Sender: TObject);
procedure stg2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.stg1TopLeftChanged(Sender: TObject);
begin
stg2.LeftCol := stg1.LeftCol;
stg2.TopRow := stg1.TopRow;
end;procedure TForm1.stg2TopLeftChanged(Sender: TObject);
begin
stg1.LeftCol := stg2.LeftCol;
stg1.TopRow := stg2.TopRow;
end;procedure TForm1.stg1Click(Sender: TObject);
begin
stg2.Row:=stg1.Row;
stg2.Col:=stg1.Col;
end;procedure TForm1.stg2Click(Sender: TObject);
begin
stg1.Row:=stg2.Row;
stg1.Col:=stg2.Col;
end;end.
将stringgrid的option中的rowselect设为true,效果很明显。
以上是我的经理的解决方法,可行。
不过我觉得还是拦截stringgrid的消息,重载WindowProc过程思路比较正统一点
fengsx (fengsx) 你先试试上面的代码,不满意我再用我的思路是试试