Solved

DBGrid and key press

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
drawing animated level bar based on numbers 3 111
Delphi and Access based Enumeration 9 77
Tidtcpserver listening on multiports? 1 44
DBCtrlGrid, Delphi, Scroll 7 32
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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