我设置了表格的大小,现在一页只能显示17条记录,如果记录数比较多的时候要用滚动条翻动,很麻烦,于是根据字段做了一个简单的查询,用来定位记录,现在记录是能定位了,但是stringgrid的表格不跟着滚动,怎么能让表格跟着滚动呢?
17条之前的记录我能看到,后面的记录还是要手动取托滚动条~!
郁闷撒。不知道大家听明白我说的意思没?
for i := 0 to sgdGXSJ.RowCount do
begin
if sgdGX.Cells[1, i] = str1 then
begin
myRect.Left := 0;
myRect.Top := i;
myRect.Right := 5;
myRect.Bottom := i;
sgdGX.Selection := myRect;
if MessageDlg('查找下一个记录, mtconfirmation, [mbyes, mbno], 0) = mrno then
begin
sgdGX.SetFocus;
Exit;
end;
end;
end;
17条之前的记录我能看到,后面的记录还是要手动取托滚动条~!
郁闷撒。不知道大家听明白我说的意思没?
for i := 0 to sgdGXSJ.RowCount do
begin
if sgdGX.Cells[1, i] = str1 then
begin
myRect.Left := 0;
myRect.Top := i;
myRect.Right := 5;
myRect.Bottom := i;
sgdGX.Selection := myRect;
if MessageDlg('查找下一个记录, mtconfirmation, [mbyes, mbno], 0) = mrno then
begin
sgdGX.SetFocus;
Exit;
end;
end;
end;
for i := 0 to sgdGX.RowCount-1 do
if sgdGX.Cells[1, i] = str1 then
begin
sgdGX.Row:=i;
sgdGX.TopRow:=i;
if MessageDlg('查找下一个记录, mtconfirmation, [mbyes, mbno], 0) = mrno then exit;
end;奉上解答,请教了单位的前辈,佩服的五体投地~!
procedure TSJMain.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.message = WM_MOUSEWHEEL) and (Msg.hwnd = sgdGXSJ.Handle) then begin
SendMessage(sgdGXSJ.Handle, WM_VSCROLL, Byte(Msg.wParam<=0), 0);
Handled := True;
end;
end;