Columnwhen condition in grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Columnwhen condition in grid

Post 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
Last edited by ROBROS on Sat Jul 17, 2021 3:58 pm, edited 1 time in total.
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Columnwhen condition in grid

Post 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.
All The Best,
Franco
Canada
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Columnwhen condition in grid

Post 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
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Columnwhen condition in grid

Post by andyglezl »

COLUMNWHEN {{||.T.},{||This.CellValue='numeric'}} && runtime argument error

Try...

COLUMNWHEN { { || .F. }, { || .T. } }
Andrés González López
Desde Guadalajara, Jalisco. México.
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Columnwhen condition in grid

Post 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
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Columnwhen condition in grid

Post 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
There's nothing you can do that can't be done...
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Columnwhen condition in grid

Post by ROBROS »

Serge,
now I understand the logic, couldn't find it in any sample.

Thank you Robert.
Post Reply