Page 1 of 1
Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 5:47 am
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?
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 7:07 am
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)
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 8:10 am
by mol
Thank you.
But, I want to do it with IDE. I don't want to define control in my .prg code
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 11:16 am
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 (22.54 KiB) Viewed 2563 times
Best regards,
Salamandra - Brazil
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 11:51 am
by mol
But, another question. How to use ON CHECKBOXCLICKED event?
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 12:02 pm
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
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 12:11 pm
by mol
You don't understand me - I want to do action when user checks position
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 12:27 pm
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()}
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 1:10 pm
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
Re: Grid with CheckBoxItems - how to define in IDE?
Posted: Tue Jun 02, 2020 1:25 pm
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