Board index » delphi » Can EnterKey Move from one cell to another?

Can EnterKey Move from one cell to another?

Hello,

I have posted this before but did not get any help hope someone can help
me.

 I want my focused cell to MOVE DOWN ONE CELL when the Enter Key is
 press, and always in edit mode when the cell is the currently selected
 one. What I am doing now is set AlwaysShowEditor to True but it does
not
 move down to the next cell when I press "enter" key. Can this be
achieved?

Thank you
Roberty

 

Re:Can EnterKey Move from one cell to another?


Quote
> I have posted this before but did not get any help hope someone can help
> me.

>  I want my focused cell to MOVE DOWN ONE CELL when the Enter Key is
>  press, and always in edit mode when the cell is the currently selected
>  one. What I am doing now is set AlwaysShowEditor to True but it does
> not
>  move down to the next cell when I press "enter" key. Can this be
> achieved?

  Easily. Attach a handler to the grids OnKeyPress event like this:

procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    with sender as tstringgrid do begin
      if row = rowcount-1 then
        rowcount := rowcount + 1;
      row := row+1;
    end;
    key := #0;
  end;
end;

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:Can EnterKey Move from one cell to another?


Thank YOU Peter! for your help. This is great..

Seeya.
Roberty

Quote
Peter Below wrote:
> > I have posted this before but did not get any help hope someone can
> help
> > me.

> >  I want my focused cell to MOVE DOWN ONE CELL when the Enter Key is
> >  press, and always in edit mode when the cell is the currently
> selected
> >  one. What I am doing now is set AlwaysShowEditor to True but it
> does
> > not
> >  move down to the next cell when I press "enter" key. Can this be
> > achieved?

>   Easily. Attach a handler to the grids OnKeyPress event like this:

> procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
> begin
>   if key = #13 then begin
>     with sender as tstringgrid do begin
>       if row = rowcount-1 then
>         rowcount := rowcount + 1;
>       row := row+1;
>     end;
>     key := #0;
>   end;
> end;

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitely requested!

Other Threads