Board index » delphi » StringGrid, how to?

StringGrid, how to?

StringGrid have a option "go tab" which can enable use tab button
emulate left arrow button
1  Can I use "Enter" to emulate that?
   I've try use SelectNext, but it's not applicable in StringGrid
2  or make it like how Excel work
    press tab, go next column
    press enter, go next row
3 disable specific column, make some column is not selectable, press TAB
will skip this column
but can change the content

thx for your advice

--
*******************************
remove .no.spam b4 send me mail
l...@hkdsl.com
*******************************

 

Re:StringGrid, how to?


Quote
In article <38A7CC19.4E01E...@hkdsl.com.no.spam>, Lh wrote:
> StringGrid have a option "go tab" which can enable use tab button
> emulate left arrow button
> 1  Can I use "Enter" to emulate that?
>    I've try use SelectNext, but it's not applicable in StringGrid

procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    key := #0;
    keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), 0, 0);
    keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), KEYEVENTF_KEYUP, 0);
    // just setting key := #9 will not do
  end;
end;

Quote
> 2  or make it like how Excel work
>     press tab, go next column
>     press enter, go next row

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

Quote
> 3 disable specific column, make some column is not selectable, press TAB
> will skip this column but can change the content

YOu can do all these things in code. The OnSelectCell event is a good
place to prevent the user from going into a cell, or to change the grids
Options to include or exclude the goEditing option, for example, to make a
column read-only. If you handle tab yourself you can directly set the
grids Col and Row properties to activate any cell you like.

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

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:StringGrid, how to?


thx for your advice, I'll try this

Quote
"Peter Below (TeamB)" wrote:
> In article <38A7CC19.4E01E...@hkdsl.com.no.spam>, Lh wrote:
> > StringGrid have a option "go tab" which can enable use tab button
> > emulate left arrow button
> > 1  Can I use "Enter" to emulate that?
> >    I've try use SelectNext, but it's not applicable in StringGrid

> procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
> begin
>   if key = #13 then begin
>     key := #0;
>     keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), 0, 0);
>     keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), KEYEVENTF_KEYUP, 0);
>     // just setting key := #9 will not do
>   end;
> end;

> > 2  or make it like how Excel work
> >     press tab, go next column
> >     press enter, go next row

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

> > 3 disable specific column, make some column is not selectable, press TAB
> > will skip this column but can change the content

> YOu can do all these things in code. The OnSelectCell event is a good
> place to prevent the user from going into a cell, or to change the grids
> Options to include or exclude the goEditing option, for example, to make a
> column read-only. If you handle tab yourself you can directly set the
> grids Col and Row properties to activate any cell you like.

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

> Sent using Virtual Access 5.00 - download your freeware copy now
> http://www.atlantic-coast.com/downloads/vasetup.exe

--
*******************************
remove .no.spam b4 send me mail
l...@hkdsl.com
*******************************

Other Threads