Grid with CheckBoxItems - how to define in IDE?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Grid with CheckBoxItems - how to define in IDE?

Post by mol »

I want to redefine piece of code and use Grid with CheckBoxItems.
I'm using IDE to design form. But, I can't see possibility for grid with CheckBoxItems. Am I wrong?
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: Grid with CheckBoxItems - how to define in IDE?

Post by fouednoomen »

See this code

aCtrl_1 := { 'CHECKBOX' , 'Ok' , 'No' }
aCtrl_2 := {'TEXTBOX','CHARACTER' ,'!!!!!!!!!!!'}
aCtrl_3 := {'TEXTBOX','CHARACTER' ,'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'}
aCtrl_4 := {'TEXTBOX','CHARACTER' ,'!!!!!!'}
aCtrl_5 := {'TEXTBOX','CHARACTER' ,'!!!!!!!!!!!'}
aCtrl_6 := {'TEXTBOX','CHARACTER' ,'99999.999'}
aCtrl_7 := {'TEXTBOX','CHARACTER' ,'!!!'}

bdDisplay_1 := { || if ( This.CellValue = .T. , 'Ok' , 'No' ) }
bdDisplay_2 := { || This.CellValue }
bdDisplay_3 := { || This.CellValue }
bdDisplay_4 := { || This.CellValue }
bdDisplay_5 := { || This.CellValue }
bdDisplay_6 := { || This.CellValue }
bdDisplay_7 := { || This.CellValue }

@ 160,10 BROWSE Browse_1 ;
WIDTH 998 ;
HEIGHT 300 ;
HEADERS {'FC','Code' , 'Raison', 'N° Doc.', 'Date' , 'Total TTC' ,'Type','OK'} ;
WIDTHS { 40,120 ,450,100,120,100,100 ,40 } ;
FONT 'Arial' ;
SIZE 12 ;
IMAGE { "UnChecked.bmp","Checked.bmp" } ;
BACKCOLOR {180,205,205} ;
WORKAREA ART_CON ;
FIELDS { "iif(ASCAN(aRecs,Recno())<>0,'.T.','F')" ,'LEFT(COD_ART,8)' , 'LEFT(DES_ART,25)','LEFT(TYPE_VEN,6)', 'DAT_COM' , 'PRIX_TTC','LEFT(CF,2)','kit'} ;
JUSTIFY { BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT , BROWSE_JTFY_RIGHT , BROWSE_JTFY_LEFT } ;
WHEN { {||.T.} , {||.F.} , {||.F.} , {||.F.} , {||.F.} , {|| .F.} , {||.F.} , {||.F.} } ;
ON DBLCLICK DblClickBrowseScreen() ;
ON CHANGE (Art_Con->(dbGoTo(Win_1.Browse_1.value )), Update_livraison() )
.
.
.
.

STATIC FUNCTION DblClickBrowseScreen
Art_Con->(dbGoTo(Win_1.Browse_1.value ))
IF This.CellColIndex == 1
SelectRecord(@aRecs,This.Value)
This.Refresh()

If Art_con->kit = .T.
Replace Art_con->kit With .F.
Else
Replace Art_con->kit With .T.
EndIf
* Msgbox(art_con->kit)
* Win_1.Browse_1.save
Win_1.Browse_1.Refresh
ENDIF

RETURN(NIL)
Attachments
grid with  CheckBoxItems.png
grid with CheckBoxItems.png (112.13 KiB) Viewed 2600 times
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid with CheckBoxItems - how to define in IDE?

Post by mol »

Thank you.
But, I want to do it with IDE. I don't want to define control in my .prg code
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: Grid with CheckBoxItems - how to define in IDE?

Post by salamandra »

Hi Mol,
mol wrote: Tue Jun 02, 2020 5:47 am I want to redefine piece of code and use Grid with CheckBoxItems.
I'm using IDE to design form. But, I can't see possibility for grid with CheckBoxItems. Am I wrong?
No, you can´t , but you can enable checkboxes at window loading time

Code: Select all

LOAD WINDOW users_edit
	ON KEY CONTROL+T OF users_edit ACTION tagAll(z)
	ON KEY CONTROL+U OF users_edit ACTION tagNone(z)
	users_edit.Title:=':: Users - Add a new user.'
	
	/* Enable checkboxes here */
	users_edit.Grid_1.CheckBoxEnabled := .T.
	
	users_edit.Grid_1.Value:=1
	users_edit.tbNomeUsuario.SetFocus
CENTER WINDOW users_edit
ACTIVATE WINDOW users_edit
It seems something like this ...
sample.PNG
sample.PNG (22.54 KiB) Viewed 2566 times




Best regards,


Salamandra - Brazil
There is one time in which is crucial awakening. That time is now. ( Buddha )
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid with CheckBoxItems - how to define in IDE?

Post by mol »

But, another question. How to use ON CHECKBOXCLICKED event?
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: Grid with CheckBoxItems - how to define in IDE?

Post by salamandra »

Hi Mol,
mol wrote: Tue Jun 02, 2020 11:51 am But, another question. How to use ON CHECKBOXCLICKED event?

This is an example about how to change row backcolor when checkbox is set to .T.

Code: Select all

LOCAL bColor := {|| if ( users_edit.Grid_1.CheckBoxItem (This.CellRowIndex) == .T. , { 202,255,202 } , { 255,255,255 } ) }

and this is an example about how to verify how many (and which) checkboxes are .T. or .F.

Code: Select all

For k:=1 TO users_edit.Grid_1.ItemCount
      h += IIF( users_edit.Grid_1.CheckBoxItem(k) == .T., 1, 0 )
Next k

Best regards,


Salamandra - Brazil
There is one time in which is crucial awakening. That time is now. ( Buddha )
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid with CheckBoxItems - how to define in IDE?

Post by mol »

You don't understand me - I want to do action when user checks position
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid with CheckBoxItems - how to define in IDE?

Post by mol »

My working code:

Code: Select all

	OknoRaportObrotuTowarow.G_Grupy.CheckBoxEnabled := .T.
	i := GetControlIndex("G_Grupy", "OknoRaportObrotuTowarow")
	_HMG_SYSDATA [ 40 ] [ i ] [ 46 ] := {||OknoRaportObrotuTowarow_G_Grupy_CheckBoxClicked()}
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: Grid with CheckBoxItems - how to define in IDE?

Post by salamandra »

Hi Mol,
You don't understand me - I want to do action when user checks position
I did not get to work the ON CHECKBOXCLICKED event when the grid it´s designed by IDE, althought this is not my need too.

Take a look at the sample at \hmg.3.4.3\SAMPLES\Controls\Grid\Grid_CheckBoxes\demo.prg


Salamandra - Brazil
There is one time in which is crucial awakening. That time is now. ( Buddha )
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid with CheckBoxItems - how to define in IDE?

Post by mol »

I'm using it for first item "Select/Unselect ALL" - if user check or uncheck first item - all others are chcecked or unchecked:

Code: Select all

if This.CellRowClicked == 1
		for i:=2 to len(aGrupyNazwy)
			OknoRaportObrotuTowarow.G_Grupy.CheckBoxItem(i) := OknoRaportObrotuTowarow.G_Grupy.CheckBoxItem(1)
		next i
	else
		if !OknoRaportObrotuTowarow.G_Grupy.CheckBoxItem(This.CellRowClicked)
			StopControlEventProcedure ( "G_Grupy", "OknoRaportObrotuTowarow", .t. )
			OknoRaportObrotuTowarow.G_Grupy.CheckBoxItem(1) := .F.
			StopControlEventProcedure ( "G_Grupy", "OknoRaportObrotuTowarow", .f. )
		endif
	endif
Post Reply