stringgrid用左右方向键如何控制水平滚动条移动

dingcaishen 2009-04-23 12:20:40
如题,scrollbars: ssboth; rowselect选中的情况下,按左,右方向键时只能上下移动,怎么才能只移动水平滚动条?
...全文
105 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dingcaishen 2009-04-24
  • 打赏
  • 举报
回复
万分感谢,结帖了
wfl568 2009-04-23
  • 打赏
  • 举报
回复
给你一段代码!

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;

type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i,j : Integer;
begin
StringGrid1.RowCount := 100;
StringGrid1.ColCount := 100;

for i:=0 to StringGrid1.RowCount -1 do
for j:=0 to StringGrid1.ColCount -1 do
StringGrid1.Cells[i,j] := IntToStr(i*j);
end;

procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_LEFT then
begin
Sendmessage(StringGrid1.Handle, WM_HSCROLL, SB_PAGELEFT, 0);
Key:=0;
end;

if Key= VK_RIGHT then
begin
Sendmessage(StringGrid1.Handle, WM_HSCROLL, SB_PAGERIGHT, 0);
Key:=0;
end;
end;

end.

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧