Solved

DBGrid and key press

Posted on 2002-04-03
4
1,103 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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