Page 1 of 1
Columnwhen condition in grid
Posted: Sat Jul 17, 2021 1:26 pm
by ROBROS
Dear friends,
I have a problem with colunwhen in grid
Code: Select all
If ! IsControlDefined (Grid_chk,lotto_1)
@ 200,20 GRID Grid_chk ;
PARENT lotto_1 ;
WIDTH 120 ;
HEIGHT 180 ;
value {1,2} ;
fontcolor {0,0,255} ;
backcolor {124,252,0} ;
widths {50,50} ;
headers {'-----','Zahl'} ;
CELLNAVIGATION ;
COLUMNCONTROLS { {'TEXTBOX','character'} , {'TEXTBOX','Numeric', '99'}} ;
items anum ;
edit ;
COLUMNWHEN {{||.T.},{||This.CellValue='numeric'}} && runtime argument error
**COLUMNWHEN {{||This.CellValue<'Z'},{||This.CellValue<1}} && this line works
Endif.
What am I doing wrong?
TIA
Robert
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 3:50 pm
by franco
I think columnwhen can only be .T. or .F.
You can use if statements for each column .
COLUMNWHEN {{||.T.},{||.T.}}
OR
COLUMNWHEN {{|| iif(HMG_GetLastVirtualKeyDown() == 13, .T., .F.)},{ || .F.}} // last key pressed was ENTER column 1 is T
Hope this helps.
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 5:45 pm
by ROBROS
Franco,
your answer brought me a step further, at least as column 2 is concerned. My intention for column 1 was to write-protect it. The grid has 6 rows and 2 columns.
Each column 1 is preset with the string "Zahl1", "Zahl2" to "Zahl6" As a digit in a character string is a character too, it doesn't work. Defining column1 of this textbox as numeric gives me of course a runtime error.
Is there a way to write-protect a column in a grid? So far, I found no answer. So I will change my grid to one dimensional and show a label with value "Zahl1" to "Zahl6".
Thank you anyway
Robert
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 6:14 pm
by andyglezl
COLUMNWHEN {{||.T.},{||This.CellValue='numeric'}} && runtime argument error
Try...
COLUMNWHEN { { || .F. }, { || .T. } }
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 6:44 pm
by ROBROS
Hi Andy,
I don't understand why, but it works.
What does .F. or .T. refer to? I think to the type of textbox in the grid.
Thanks a lot
Robert
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 7:03 pm
by serge_girard
Robert,
COLUMNWHEN { {|| FALSE }, { || FALSE }, {|| FALSE }, {|| FALSE }, {|| TRUE }, {|| FALSE } , {|| FALSE }}
COLUMNCONTROLS { { 'TEXTBOX', 'NUMERIC' }, ;
{ 'TEXTBOX', 'CHARACTER' }, ;
{ 'TEXTBOX', 'NUMERIC' }, ;
{ 'TEXTBOX', 'NUMERIC' }, ;
{ 'TEXTBOX', 'NUMERIC' }, ;
{ 'TEXTBOX', 'NUMERIC' }, ;
{ 'TEXTBOX', 'CHARACTER' }}
ALLOWEDIT TRUE
means that column 5 is editable and all other are non-editable.
false = .f. and true = .t. !
Serge
Re: Columnwhen condition in grid
Posted: Sat Jul 17, 2021 7:15 pm
by ROBROS
Serge,
now I understand the logic, couldn't find it in any sample.
Thank you Robert.