Page 2 of 4

Re: CheckBox in a Grid Problem

Posted: Thu Aug 11, 2022 1:22 pm
by serge_girard
Red,

Make a small demo.prg with this grid and extract from your dbf. Then post it here!

Serge

Re: CheckBox in a Grid Problem

Posted: Thu Aug 11, 2022 10:23 pm
by Red2
Hi All,

Thank you all for you kind suggestions.
I made two discoveries about the ColumnControl for Column #1.

1) If ColumnControls[1] is {"CHECKBOX, "Yes", "No"} then my DynamicBackColor is not correct.
The part of DynamicBackColor that uses Column #1's Value Fails.
It should display a Column #1 .T. (value) row in GREEN.
I can successfully use {"CHECKBOX"} but still no CheckBox control appears.
BkColor_Examples.PNG
BkColor_Examples.PNG (4.19 KiB) Viewed 4786 times
2) Also, when this (Fails) happens I cannot programmatically read or update Column #1's Value.

Code: Select all

llThisCellVal := GetProperty( "DataBrowse", "BrowseStates", "CellEx", lnGridRowNr, 1 ) // Always returns Nil!
Until today I did not know what was causing this incorrect Nil value "bug".

Mol: A ColumnControls[1] Value of NIL displays just the same as {"CHECKBOX"}. No CheckBox appears.

Serge, I will post some simple code that demonstrates my Grid.
Unfortunately I have some other things going on that will delay this for a day or two.

Thank you all for your great help!
Red2

Re: CheckBox in a Grid Problem

Posted: Fri Aug 12, 2022 12:00 am
by franco
Hi, Red2 What field are you using for index. is it you checkbox field.
I just moved field 5 of samples grid36 to 1 andit works fine.
I will try to check DynamicBackColor now.

Re: CheckBox in a Grid Problem

Posted: Fri Aug 12, 2022 12:17 am
by franco
I don`t know if this what you want. Any other Dynamicbackcolor is I think the same grid problem I am having.
The only dynamicbackcolor I can get towork is row cells. if I add anything else it does not work.
This is grid36 in grid samples with my changes.

Code: Select all

public bcolor := { || if( this.Cellrowindex/2 == int(this.CellRowIndex/2), {210,120,255}, {100,200,255})}       // I added
	* Grid Column Controls Definitions

	aCtrl_1 := {'TEXTBOX','NUMERIC','9999999999'}
	aCtrl_2 := {'TEXTBOX','CHARACTER'}
	aCtrl_3 := {'TEXTBOX','CHARACTER'}
	aCtrl_4 := {'DATEPICKER','UPDOWN'}
	aCtrl_5 := { 'CHECKBOX' , 'Yes' , 'No' }
	aCtrl_6 := {'TEXTBOX','CHARACTER'}

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 800 ;
		HEIGHT 510 ;
		TITLE 'Hello World!' ;
		MAIN 

		DEFINE MAIN MENU 
			POPUP 'File'
				ITEM 'Append (Alt+A)'				ACTION Form_1.Grid_1.Append
				ITEM 'Set RecNo'				ACTION Form_1.Grid_1.RecNo := val(InputBox('','')) 
				ITEM 'Get RecNo'				ACTION MsgInfo( Str(Form_1.Grid_1.RecNo) )
				ITEM 'Delete (Alt+D)'				ACTION Form_1.Grid_1.Delete
				ITEM 'Recall (Alt+R)'				ACTION Form_1.Grid_1.Recall
				ITEM 'Get Value'				ACTION ( aValue := Form_1.Grid_1.Value , MsgInfo( Str( aValue [1] ) + ' , ' + Str( aValue [2] ) ) )
				ITEM 'Set Value'				ACTION ( aValue [ 1 ] :=  val(InputBox('New Row','Selected Cell (Value)')) , aValue [ 2 ] :=  val(InputBox('New Col','Selected Cell (Value)')) , Form_1.Grid_1.Value := { aValue [ 1 ] , aValue [ 2 ] } )
				ITEM 'Save Pending Changes (Alt+S)'		ACTION Form_1.Grid_1.Save
				ITEM 'Clear Changes Buffer (Undo) (ALt+U)'	ACTION Form_1.Grid_1.ClearBuffer
			END POPUP
		END MENU

		*.............................................................

		SELECT 1

		USE TEST ALIAS TEST

		INDEX ON CODE TO TEST_CODE

		GO TOP

		*..............................................................

		SELECT 2

		USE CHILD ALIAS CHILD

		INDEX ON CODE TO CHILD_CODE

		GO TOP

		*..............................................................

		SELECT 1

		SET RELATION TO CODE INTO CHILD

		GO TOP

		*..............................................................

		@ 10,10 grid Grid_1 ;
			WIDTH 770 ;
			HEIGHT 440 ;
			HEADERS {'Column 5','Column 1','Column 2','Column 3','Column 4','Column 6'} ;
			WIDTHS {100,140,140,140,100,110};     // I changed
			FONT "ARIAL" SIZE 8;
			EDIT ;
			VALUE { 1 , 1 } ;
			COLUMNCONTROLS { aCtrl_5 , (aCtrl_1) , aCtrl_2 , aCtrl_3 , aCtrl_4 , aCtrl_6 } ;         // I changed
			ROWSOURCE "Test" ;
			COLUMNFIELDS { 'Married', 'Code' ,  'First' , 'Last' ,  'Birth' , 'child->info' } ;         // I changed
			ALLOWDELETE ;
			DYNAMICBACKCOLOR {BCOLOR,BCOLOR,BCOLOR,BCOLOR,BCOLOR,BCOLOR}           // I added

  
 
		
	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return

Re: CheckBox in a Grid Problem

Posted: Fri Aug 12, 2022 11:16 am
by serge_girard
Red2,

Such a small demo as this will do:

Code: Select all

 
 #include "hmg.ch"



FUNCTION MAIN()
/***************/

aARQ  := {}
AADD( aARQ , { 'F1'      , 'N'	, 7	, 0 } )
AADD( aARQ , { 'F2'      , 'C'	, 10	, 0 } )
AADD( aARQ , { 'F3' 	    , 'C'   , 10 	, 0 } )
AADD( aARQ , { 'F4' 	    , 'D'   , 8 	, 0 } )
AADD( aARQ , { 'F5' 	    , 'L'   , 1 	, 0 } )
AADD( aARQ , { 'F6' 	    , 'C'   , 10 	, 0 } )
DBCREATE( "TESTRED2" , aARQ  )	  

SELECT 1
USE TESTRED2
GO TOP

APPEND BLANK
REPLACE F1  WITH 123
REPLACE F2  WITH '123'
REPLACE F3  WITH '123'
REPLACE F4  WITH DATE()-123
REPLACE F5  WITH .f.
REPLACE F6  WITH 'F6'

APPEND BLANK
REPLACE F1  WITH 321
REPLACE F2  WITH '312'
REPLACE F3  WITH '321'
REPLACE F4  WITH DATE()-123
REPLACE F5  WITH .T.
REPLACE F6  WITH 'F6'

APPEND BLANK
REPLACE F1  WITH 123
REPLACE F2  WITH '123'
REPLACE F3  WITH '123'
REPLACE F4  WITH DATE()-1 
REPLACE F5  WITH .f.
REPLACE F6  WITH 'F6'

APPEND BLANK
REPLACE F1  WITH 321
REPLACE F2  WITH '312'
REPLACE F3  WITH '321'
REPLACE F4  WITH DATE() 
REPLACE F5  WITH .T.
REPLACE F6  WITH 'F6'


public bcolor := { || if( this.Cellrowindex/2 == int(this.CellRowIndex/2), {210,120,255}, {100,200,255})}    

aCtrl_1 := {'TEXTBOX','NUMERIC','9999999999'}
aCtrl_2 := {'TEXTBOX','CHARACTER'}
aCtrl_3 := {'TEXTBOX','CHARACTER'}
aCtrl_4 := {'DATEPICKER','UPDOWN'}
aCtrl_5 := {'CHECKBOX' , 'Yes' , 'No' }
aCtrl_6 := {'TEXTBOX','CHARACTER'}

DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 800 ;
   HEIGHT 510 ;
   TITLE 'Hello Red2!' ;
   MAIN 

   @ 10,10 grid Grid_1 ;
      WIDTH 770 ;
      HEIGHT 440 ;
      HEADERS {'Column 1','Column 2','Column 3','Column 4','Column 5','Column 6'} ;
      WIDTHS {100,140,140,140,100,110};      
      FONT "ARIAL" SIZE 8;
      EDIT ;
      VALUE { 1 , 1 } ;
      COLUMNCONTROLS { aCtrl_1 , (aCtrl_2) , aCtrl_3 , aCtrl_4 , aCtrl_5 , aCtrl_6 } ;        
      ROWSOURCE "TESTRED2" ;
      COLUMNFIELDS { 'F1', 'F2' ,  'F3' , 'F4' ,  'F5' , 'F6' } ;          
      ALLOWDELETE ;
      DYNAMICBACKCOLOR {BCOLOR,BCOLOR,BCOLOR,BCOLOR,BCOLOR,BCOLOR}           

   
END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

RETURN
		 
Serge

Re: CheckBox in a Grid Problem

Posted: Fri Aug 12, 2022 2:05 pm
by franco
Yes Serge, but I think Red2 wants his checkbox cell to be red when .F., green when .T.

Re: CheckBox in a Grid Problem

Posted: Sun Aug 14, 2022 11:59 pm
by Red2
Hi Everyone,

Thank you all for your kind suggestions and advice!

In the attached .ZIP file is my example code.
1) It uses HMG's IDE
2) It creates the sample .DBF file that the Grid displays.
3) Column #1 of the Grid, displays the Logical field, By_State->MergeState
4) The Grid's COLUMNCONTROLS array is generated in function DataBrowse_OnInit()

I REALLY appreciate everyone's ideas and guidance.

Thanks again,
Red2

Re: CheckBox in a Grid Problem

Posted: Mon Aug 15, 2022 7:07 am
by serge_girard
Hi Red2

I can't get it working neither..! Maybe Grigory has a solution?

Serge

Re: CheckBox in a Grid Problem

Posted: Mon Aug 15, 2022 9:49 pm
by AUGE_OHR
hi Red,

i have look into your Sample and wonder why you use COLUMNCONTROLS :?:

i do not "see" that COLUMNCONTROLS "in Header" of GRID.
i do "see" .F. / .T. in 1st Column

---

i have try with GRID ... but it seem not to work ...
here a Sample using BROWSE which work
Solution_14.jpg
Solution_14.jpg (37.44 KiB) Viewed 4688 times
Solution_Example14.zip
(5.8 KiB) Downloaded 97 times

Re: CheckBox in a Grid Problem

Posted: Mon Aug 15, 2022 11:06 pm
by Red2
Hi JImmy,

Thank you for your kind suggestion. I appreciate it.

More Information:
My display originally used a Browse Control.
I changed it to a Grid Control so Column #1 would display a CheckBox.
For my needs a Grid works OK because no rows will ever be added or deleted.

I want the user to interact with Column #1 using a CheckBox.
The HMG sample C:\HMG.3.4.4\Samples\Controls\Grid\Grid_CheckBoxes\Demo.PRG is appropriate:
Grid_CheckBoxes_Demo.PNG
Grid_CheckBoxes_Demo.PNG (21.81 KiB) Viewed 4683 times
Unfortunately I have been not been able to make this happen using:
1) The HMG IDE and
2) Displaying a .DBF table instead of a data Array.
I am still looking for a successful result.

Thank you again for your expert guidance.
Red2