Topic: Multiple tGrid focus on same form

I wanted use Derek's showing selected record details without SQL on same record.

It works fine with one tGrid on same form but couldn't make it work when added additional tGrid on same form.


Hopefully Derek is around to help.....


Please see attached sample project.

Post's attachments

Attachment icon Showing Details Without SQL Two Grids.zip 11.24 kb, 347 downloads since 2017-07-28 

Adam
God... please help me become the person my dog thinks I am.

2 (edited by derek 2017-07-29 22:46:49)

Re: Multiple tGrid focus on same form

Hi Adam,
Is this the sort of thing that you're after?
It was easier to start with a blank script so you might want to cut and paste this back to your original (or vice versa).
Derek.

Post's attachments

Attachment icon wip.zip 344.2 kb, 381 downloads since 2017-07-29 

3 (edited by AD1408 2017-07-30 04:59:08)

Re: Multiple tGrid focus on same form

Hi Derek,


Thank you very much............
Truly appreciated...................


As far as I can see, there is one issue remains:
When there is no record on tGrid/s I get info - error dialog "No record selected for editing." on app start and when last record on tGrid deleted.
I couldn't find a way to kill it.

Adam
God... please help me become the person my dog thinks I am.

Re: Multiple tGrid focus on same form

As far as I can see, there is one issue remains:
When there is no record on tGrid/s I get info - error dialog "No record selected for editing." on app start and when last record on tGrid deleted.


Any solution?

Adam
God... please help me become the person my dog thinks I am.

Re: Multiple tGrid focus on same form

Check it out
procedure derekwhichsheetisactive;  //*** highlight grid row in each tabsheet
begin
  if form1.PageControl1.ActivePage = form1.tabsheet1 then
    begin
      if form1.gridemployees.selectedrow < 0 then form1.gridemployees.selectedrow := 0;
      vrowid := form1.gridemployees.selectedrow;
      if form1.gridemployees.selectedrow > -1 then form1.button1.click;
      form1.gridemployees.selectedrow := vrowid;
      form1.gridemployees.setfocus;
    end;
  if form1.PageControl1.ActivePage = form1.tabsheet2 then
    begin
      if form1.gridproducts.selectedrow < 0 then form1.gridproducts.selectedrow := 0;
      vrowid := form1.gridproducts.selectedrow;
      if form1.gridproducts.SelectedRow > -1 then form1.button5.click;
      form1.gridproducts.selectedrow := vrowid;
      form1.gridproducts.setfocus;
    end;
end;
Dmitry.

Re: Multiple tGrid focus on same form

Thank you very much Dmitry....................
Truly appreciated......................

Adam
God... please help me become the person my dog thinks I am.