Board index » delphi » Navigating in DBGrid using <enter>- key

Navigating in DBGrid using <enter>- key

Hi,

Moving to the next field, next and previos record, the TAB and lower and upper keys will
be used to move in a DBGrid. In our application we want to move to the next field
and next record inb case the <ENTER>-key is pressed. Using the OnKeyPressed event
(to capture the <ENTER> key) one is possible to move the pointer to the next field
by changing the SelectIndex to the appropiate field. But I am still struggling with
the problem how to move to the next record without using the arrow key.

Any ideas how to solve this problem.

Thanks

 

Re:Navigating in DBGrid using <enter>- key


Quote
ch...@emt.ie.philips.nl wrote:

> Hi,

> Moving to the next field, next and previos record, the TAB and lower and upper keys will
> be used to move in a DBGrid. In our application we want to move to the next field
> and next record inb case the <ENTER>-key is pressed. Using the OnKeyPressed event
> (to capture the <ENTER> key) one is possible to move the pointer to the next field
> by changing the SelectIndex to the appropiate field. But I am still struggling with
> the problem how to move to the next record without using the arrow key.

> Any ideas how to solve this problem.

> Thanks

Try something like this:

         if selectedindex < (fieldcount-1) then
           selectedindex := selectedindex+1
         else
         begin
           datasource.dataset.next;
           if datasource.dataset.EOF then
             datasource.dataset.Append;
           selectedindex := 0;
         end;

Other Threads