1 (edited by AD1408 2018-02-08 06:45:57)

Topic: Grid Focus ?

https://s17.postimg.org/a64loh67z/tempz002.png


As illustrated above, I was trying to use Derek's myScroll script to achieve;
♦ Form1 onShow
    - select first available record from upper pageControl
    - Selected record details displayed on the lower pageControl.


The following script for customers tab works but I couldn't get Suppliers and Product tabs work?

var  vrowid: integer;
// Customer
procedure MyScrollCUSTOMER;
begin
if Form1.PageControl1.ActivePageIndex = 0 then
   begin
   if Form1.tgMainCustomers.selectedrow < 0 then Form1.tgMainCustomers.selectedrow := 0;
      vrowid := Form1.tgMainCustomers.selectedrow;
      Form1.tgMainCustomers.selectedrow := vrowid;
      Form1.tgMainCustomers.setfocus;
   end;
end;

// Supplier
procedure MyScrollSUPPLIER;
begin
if Form1.PageControl1.ActivePageIndex = 1 then
   begin
   if Form1.tgMainSupplier.selectedrow < 0 then Form1.tgMainSupplier.selectedrow := 0;
      vrowid := Form1.tgMainProducts.selectedrow;
      Form1.tgMainSupplier.selectedrow := vrowid;
      Form1.tgMainSupplier.setfocus;
   end;
end;

// Product
procedure MyScrollPRODUCT;
begin
if Form1.PageControl1.ActivePageIndex = 2 then
   begin
   if Form1.tgMainProducts.selectedrow < 0 then Form1.tgMainProducts.selectedrow := 0;
      vrowid := Form1.tgMainProducts.selectedrow;
      Form1.tgMainProducts.selectedrow := vrowid;
      Form1.tgMainProducts.setfocus;
   end;
end;
Adam
God... please help me become the person my dog thinks I am.

Re: Grid Focus ?

Adam,
One thing that I notice is in your MyScrollSUPPLIER procedure you are loading the tgMainProducts selectedrow. I think it should be tgMainSupplier selectedrow.

procedure MyScrollSUPPLIER;
begin
if Form1.PageControl1.ActivePageIndex = 1 then
   begin
   if Form1.tgMainSupplier.selectedrow < 0 then Form1.tgMainSupplier.selectedrow := 0;
      vrowid := Form1.tgMainProducts.selectedrow;          // This should be vrowid := Form1.tgMainSupplier.selectedrow;
      Form1.tgMainSupplier.selectedrow := vrowid;
      Form1.tgMainSupplier.setfocus;
   end;
end;

l

Re: Grid Focus ?

Hi EHW,


Thank you very much..........................


I also noticed that at later stage but forgot to update it here.


After correcting, it still didn't work, most likely I must be still doing something wrong. Then I decided to use Mathias approach with combination of some SQLExecute for browsing records. It's seems fine for save, edit and delete buttons atm. However, I couldn't get it working on form1Show selecting first records on relevant grids as switching tab pages automatically..

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

Re: Grid Focus ?

Adam,
Not exactly sure what you mean by:

form1Show selecting first records on relevant grids as switching tab pages automatically.


If it's what I think you mean, you probably also need to set corresponding tablegrid rows when changing tabsheets ( Pagecontrol OnChange event)