Solved

DBGrid and key press

Posted on 2002-04-03
4
1,176 Views
Last Modified: 2010-04-04
If you press  the down/up arrow key, then the selected row will scroll down/up so long how much you press the key .

I wish to scroll just on time for each key press . If I keep pressed the down button then I wish to go to the next record and then stop untill I will press again the key .

How to do that ?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6917234
Something like this might work.

var
  bKeyUp: Boolean = True;

procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  if (Key = VK_DOWN) then begin
    if bKeyUp then
      bKeyUp := False
    else
      Key := 0;
  end;

end;

procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  bKeyUp := True;

end;


The Crazy One
0
 
LVL 44

Accepted Solution

by:
CrazyOne earned 50 total points
ID: 6917238
Actually I forgot the KeyUp part of the equtation

var
  bKeyUp: Boolean = True;

procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  if Key in [VK_DOWN, VK_UP] then begin
    if bKeyUp then
      bKeyUp := False
    else
      Key := 0;
  end;

end;

procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

  bKeyUp := True;

end;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6917820
Thanks for help.
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6917877
Glad to have been able to help. :>)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question