SetProperty for GRID

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

SetProperty for GRID

Post by serge_girard »

Hello All,

I have an application with several pages and on most pages there is a grid defined with checkboxes.
Besides the grid are 2 labels for SELECT ALL/UNSELECT.

Code: Select all

DEFINE GRID Grid_xxx	 
   ROW 25
   COL 20
   WIDTH  540
   HEIGHT 200
   HEADERS {'Commodities', 'Description',  'Move'  } 
   WIDTHS  {155,         155 ,              55     }
   CELLNAVIGATION TRUE
   COLUMNWHEN     {  {|| FALSE }, {|| FALSE }, {|| TRUE } } 
   JUSTIFY {GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT  } 
   COLUMNCONTROLS {   { 'TEXTBOX',  'CHARACTER'}, ;																 
                      { 'TEXTBOX',  'CHARACTER'}, ;	
                      { 'CHECKBOX', 'Yes' , 'No' }}
   ALLOWEDIT      TRUE
   ITEMS aGrid_xxx
END GRID     

@ 170,580 LABEL Label_On;
   VALUE "All" ;
   WIDTH 80 ;
   HEIGHT 25 ;
   FONT 'Arial' SIZE 09 ;
   BACKCOLOR GREEN ;
   ACTION Select_OnOff('Grid_xxx', 3, .T.)

@ 200,580 LABEL Label_Off ;
   VALUE "None" ;
   WIDTH  80 ;
   HEIGHT 25 ;
   FONT 'Arial' SIZE 09 ;
   BACKCOLOR RED ;
   ACTION Select_OnOff('Grid_xxx', 3, .F.)

To refer to the cell with the checkbox I need something to replace:
Form_1.Grid_xxx.Cell (i,3) := xOn // This works fine but for every grid there is almost the same function needed
with
SetProperty('Form_1', xGrid, xCel, xOn)

So the grid is variable and the position of the checkbox is also variable (but could be move to the first column, if needed).

Code: Select all

FUNCTION Select_OnOff(xGrid, xPos, xOn)
/*************************************/
nItemCount := GetProperty('Form_1', xGrid, 'ItemCount')

FOR i = 1 TO nItemCount  
   xCel  := 'Cell(i,' + ALLTRIM(STR(xPos)) + ')'                // this doen't work
   SetProperty('Form_1', xGrid, xCel, xOn)
NEXT i

FOR i = 1 TO Form_1.Grid_xxx.ItemCount                   // this works fine but it is hardcoded
   Form_1.Grid_xxx.Cell (i,3) := xOn
NEXT i 

RETURN
So I need just ONE function in order to SELECT/UNSELECT all checkboxes in any grid...

Any body an idea for the right SetProperty syntax?

Greetings and thanks,


Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: SetProperty for GRID

Post by serge_girard »

Just found the solution:

xCel := 'Cell(' + ALLTRIM(STR(i)) + ',' + ALLTRIM(STR(xPos)) + ')'

Serge
There's nothing you can do that can't be done...
User avatar
srvet_claudio
Posts: 2220
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: SetProperty for GRID

Post by srvet_claudio »

Hi Serge.

The syntax is:

Form_1.Grid_xxx.Cell (i,3) := xOn ---> SetProperty ('Form_1', "Grid_xxx", "Cell", i, xPos, xOn)
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: SetProperty for GRID

Post by serge_girard »

Thanks Claudio !
There's nothing you can do that can't be done...
Post Reply