CheckBox in a Grid Problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

Re: CheckBox in a Grid Problem

Post by serge_girard »

Red,

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

Serge
There's nothing you can do that can't be done...
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post 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 4782 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
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: CheckBox in a Grid Problem

Post 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.
All The Best,
Franco
Canada
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: CheckBox in a Grid Problem

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

Re: CheckBox in a Grid Problem

Post 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
There's nothing you can do that can't be done...
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: CheckBox in a Grid Problem

Post by franco »

Yes Serge, but I think Red2 wants his checkbox cell to be red when .F., green when .T.
All The Best,
Franco
Canada
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post 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
Attachments
Example_14-August.ZIP
(3.93 KiB) Downloaded 126 times
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: CheckBox in a Grid Problem

Post by serge_girard »

Hi Red2

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

Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CheckBox in a Grid Problem

Post 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 4684 times
Solution_Example14.zip
(5.8 KiB) Downloaded 97 times
have fun
Jimmy
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post 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 4679 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
Post Reply