Recent

Author Topic: Move to next column if entered column is read only  (Read 690 times)

daveinhull

  • Full Member
  • ***
  • Posts: 184
  • 1 divided by nothing must still be 1!
Move to next column if entered column is read only
« on: December 02, 2018, 11:17:44 am »
Hi,

Could anyone point me in the right direction to work out how to move to the next column in a DBGrid if the entered column is read only.

Thanks
Dave
« Last Edit: December 30, 2018, 05:21:35 pm by daveinhull »
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

sash

  • Full Member
  • ***
  • Posts: 179
Re: Move to next column if entered column is read only
« Reply #1 on: December 02, 2018, 09:32:50 pm »
Something like that (not tested)
Code: Pascal  [Select]
  1. procedure TForm1.DBGrid1ColEnter(Sender : TObject);
  2. begin
  3.   with DBGrid1 do begin
  4.     if Assigned(SelectedColumn) and (not SelectedColumn.ReadOnly then
  5.       if SelectedColumn <> LastColumn then // handle (ignore) last column
  6.         SelectedIndex := SelectedIndex + 1;
  7.   end;
  8. end;

Upd: should you care (and will be next OnColEnter triggered) if next column is readonly too?
« Last Edit: December 02, 2018, 09:42:34 pm by sash »
Lazarus 1.8.4 Unversioned directory FPC 3.0.4 x86_64-linux-gtk2 -- Ubuntu 18.04 XFCE

daveinhull

  • Full Member
  • ***
  • Posts: 184
  • 1 divided by nothing must still be 1!
Re: Move to next column if entered column is read only
« Reply #2 on: December 28, 2018, 05:13:03 pm »
Hi sash,

Sorry I missed your reply, many thanks

Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64