Solved

DBGrid and key press

Posted on 2002-04-03
4
1,002 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for help.
0
 
LVL 44

Expert Comment

by:CrazyOne
Comment Utility
Glad to have been able to help. :>)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now