Page 1 of 1

SetProperty for GRID

Posted: Sat Feb 08, 2014 1:21 pm
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

Re: SetProperty for GRID

Posted: Sat Feb 08, 2014 1:24 pm
by serge_girard
Just found the solution:

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

Serge

Re: SetProperty for GRID

Posted: Sat Feb 08, 2014 2:09 pm
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)

Re: SetProperty for GRID

Posted: Sat Feb 08, 2014 2:18 pm
by serge_girard
Thanks Claudio !