Recent

Author Topic: [SOLVED]DBGrid, the cursor won't move to the persistent field.  (Read 421 times)

Focus77

  • New Member
  • *
  • Posts: 25
Hi every body!

I have a dbgrid with 5 fields+a persistent field.

Autoadvance is at aaRightDown.

I  use RETURN to move between the columns .

But when the cursor is on the fifth column, it would not move to the persistent one. :(

is it a bug?
« Last Edit: June 10, 2020, 06:51:44 pm by Focus77 »
My goal is to make a web Application
using HTTPServer

jamie

  • Hero Member
  • *****
  • Posts: 3541
Re: DBGrid, the cursor won't move to the persistent field.
« Reply #1 on: June 08, 2020, 11:12:18 pm »
Isn't a persistent field a Read only? if so then what good would be the cursor there ?
The only true wisdom is knowing you know nothing

Focus77

  • New Member
  • *
  • Posts: 25
Re: DBGrid, the cursor won't move to the persistent field.
« Reply #2 on: June 08, 2020, 11:40:18 pm »
Hi there

Of course the persistent field is a read only, but the cursor must cross it, in order to get
the next row.

for this I used the next code:
Code: Pascal  [Select][+][-]
  1. procedure TF_MAINFORM.DBGrid2KeyDown(Sender: TObject; var Key: Word;
  2.   Shift: TShiftState);
  3. begin
  4.   if key=VK_RETURN then
  5.      if DBGrid2.SelectedColumn.Index=4 then
  6.       DBGrid2.SelectedIndex:=5;
  7. end;  
« Last Edit: June 08, 2020, 11:42:00 pm by Focus77 »
My goal is to make a web Application
using HTTPServer

jamie

  • Hero Member
  • *****
  • Posts: 3541
Re: DBGrid, the cursor won't move to the persistent field.
« Reply #3 on: June 09, 2020, 12:04:03 am »
maybe you should be cycling the columns each time you move up or down and always check for the field type and if not desirable then go to the next one until you fine one that is ..

 if you come to the end before you find one then you just don't move …

The only true wisdom is knowing you know nothing

Focus77

  • New Member
  • *
  • Posts: 25
Re: DBGrid, the cursor won't move to the persistent field.
« Reply #4 on: June 09, 2020, 10:53:49 pm »
Hi every one !

@jamie
In fact the only fields I can input the data are 1,2 and 3.

the code became:
Code: Pascal  [Select][+][-]
  1. procedure TF_MAINFORM.DBGrid2KeyDown(Sender: TObject; var Key: Word;
  2.   Shift: TShiftState);
  3. begin
  4.   if key=VK_RETURN then
  5.      if DBGrid2.SelectedColumn.Index<3 then
  6.       DBGrid2.SelectedIndex:=DBGrid2.SelectedIndex+1
  7.       else
  8.       begin
  9.       DBGrid2.SelectedIndex:=1;
  10.       if not MDT.T_NOTE.EOF
  11.       then MDT.T_NOTE.Next
  12.       end;
  13.  end;      
« Last Edit: June 10, 2020, 06:52:18 pm by Focus77 »
My goal is to make a web Application
using HTTPServer

 

TinyPortal © 2005-2018