Re: color in cell and color in a grid line
Posted: Sun Jul 22, 2018 3:33 am
If you put the following when adding
DoMethod( 'Form_Grid', "Grid_1", "Refresh", .T. )
DoMethod( 'Form_Grid', "Grid_1", "Refresh", .T. )
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://www.hmgforum.com/
Quizá quisiste decir "Color" en vez de "Valor" ???I can not delete the grid items just add new items,
but the already added items will change the value
of just one cell and when that happens I need to change the cell's heart.
------------------------------------------------------------------------------------------------------------------------------------------
No puedo eliminar los elementos de la grilla simplemente agregue
nuevos elementos, pero los elementos ya agregados cambiarán el
valor de una sola celda y cuando eso suceda necesito cambiar el corazón de la celda.
Code: Select all
#include "hmg.ch"
#define _DEMO_GRID_
#ifdef _DEMO_GRID_
declare windown form_1
Function Main
Local aRows := {}
Private bColor:= { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2), BLUE , RED ) } // {} // ******************************
Private fColor:= {}
//IF HMG SUPPORT UNICODE RUN
// IF HMG SUPPORT UNICODE STOP
// MsgDebug demo
//---------------------------------------------------------------------------------------
n:= 10
aData := { "Number", 38, "aRGB", YELLOW, "Hello" }
// cMsg := MsgDebug ( TIME(), aData, {|| NIL}, .F., EVAL({|| DATE ()}), n == 3 )
aRows := ARRAY (20)
aRows [1] := {'Simpson', 'Homer', '555-5555', 1, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [2] := {'Mulder', 'Fox', '324-6432', 2, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [3] := {'Smart', 'Max', '432-5892', 3, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [4] := {'Grillo', 'Pepe', '894-2332', 4, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [5] := {'Kirk', 'James', '346-9873', 5, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [6] := {'Barriga', 'Carlos', '394-9654', 6, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [7] := {'Flanders', 'Ned', '435-3211', 7, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [8] := {'Smith', 'John', '123-1234', 8, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [9] := {'Pedemonti', 'Flavio', '000-0000', 9, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [10] := {'Gomez', 'Juan', '583-4832', 10, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [11] := {'Fernandez', 'Raul', '321-4332', 11, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [12] := {'Borges', 'Javier', '326-9430', 12, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [13] := {'Alvarez', 'Alberto', '543-7898', 13, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [14] := {'Gonzalez', 'Ambo', '437-8473', 14, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [15] := {'Batistuta', 'Gol', '485-2843', 15, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [16] := {'Vinazzi', 'Amigo', '394-5983', 16, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [17] := {'Pedemonti', 'Flavio', '534-7984', 17, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [18] := {'Samarbide', 'Armando', '854-7873', 18, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [19] := {'Pradon', 'Alejandra', '???-????', 19, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
aRows [20] := {'Reyes', 'Monica', '432-5836', 20, HMG_TimeToTime( TIME(), _TIMESHORT12H )}
//bColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , {128,128,128} , {192,192,192} ) }
//fColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , BLUE , RED ) }
// CellNavigationColor (_SELECTEDCELL_FORECOLOR, BROWN)
//CellNavigationColor (_SELECTEDCELL_BACKCOLOR, GREEN)
// CellNavigationColor (_SELECTEDCELL_DISPLAYCOLOR, .T.)
// CellNavigationColor (_SELECTEDROW_FORECOLOR, YELLOW)
// CellNavigationColor (_SELECTEDROW_BACKCOLOR, BROWN)
// CellNavigationColor (_SELECTEDROW_DISPLAYCOLOR, .T.)
/*
Form_1.Grid_1.ColumnHEADER (1) := "--- Last Name ---"
Form_1.Grid_1.ColumnWIDTH (1) := 100
Form_1.Grid_1.ColumnJUSTIFY (1) := GRID_JTFY_CENTER
Form_1.Grid_1.ColumnCONTROL (1) := {'TEXTBOX','CHARACTER','@!'}
Form_1.Grid_1.ColumnDYNAMICFORECOLOR (1) := {|| BLACK}
Form_1.Grid_1.ColumnDYNAMICBACKCOLOR (1) := {|| PURPLE}
Form_1.Grid_1.ColumnVALID (1) := {|| NIL}
Form_1.Grid_1.ColumnWHEN (1) := {|| NIL}
Form_1.Grid_1.ColumnONHEADCLICK (1) := {|| MsgInfo (Form_1.Grid_1.ColumnHEADER(1))}
Form_1.Grid_1.ColumnONHEADCLICK (3) := {|| Form_1.Grid_1.ColumnWIDTH (3) := GRID_WIDTH_AUTOSIZEHEADER}
Form_1.Grid_1.ColumnONHEADCLICK (5) := {|| Form_1.Grid_1.ColumnWIDTH (5) := GRID_WIDTH_AUTOSIZE}
*/
Load Window Fomr_1
FOR i=1 TO 20
Fomr_1.Grid_1.AddItem ( {'lolo','JUAN','333-9999', 21, HMG_TimeToTime(TIME(),_TIMESHORT12H)} ) // Added this item in the END of the GRID
Fomr_1.Grid_1.AddItemEx ( {'Lolo','LOLO','333-9999', 22, HMG_TimeToTime(TIME(),_TIMESHORT12H)}, NIL ) // Added this item in the END of the GRID
Fomr_1.Grid_1.AddItemEx ( {'hmg', 'JUAN','333-9999', 23, HMG_TimeToTime(TIME(),_TIMESHORT12H)}, 3 ) // Added this item in Row 3
NEXT
Fomr_1.Center
Fomr_1.Activate
Return
function cor()
bColor := { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2), BLUE , RED ) }
//bColor := { || RED }
//DoMethod( 'Fomr_1', "Grid_1", "Refresh", .T. )
return
#endif
andyglezl wrote: ↑Sun Jul 22, 2018 7:58 pm Yo sigo sin entender...
-----------------------------
I still dont get it...
Quizá quisiste decir "Color" en vez de "Valor" ???I can not delete the grid items just add new items,
but the already added items will change the value
of just one cell and when that happens I need to change the cell's heart.
------------------------------------------------------------------------------------------------------------------------------------------
No puedo eliminar los elementos de la grilla simplemente agregue
nuevos elementos, pero los elementos ya agregados cambiarán el
valor de una sola celda y cuando eso suceda necesito cambiar el corazón de la celda.
-----------------------------------------------------------
Maybe you wanted to say "Color" instead of "Value" ???
De la siguiente forma, los elementos tienen el mismo color que todos los demas del grid.
-----------------------------------------------------------------------------------------------------------------------------
In the following way, the elements have the same color as all the other elements of the grid.
Code: Select all
#include "hmg.ch" #define _DEMO_GRID_ #ifdef _DEMO_GRID_ declare windown form_1 Function Main Local aRows := {} Private bColor:= { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2), BLUE , RED ) } // {} // ****************************** Private fColor:= {} //IF HMG SUPPORT UNICODE RUN // IF HMG SUPPORT UNICODE STOP // MsgDebug demo //--------------------------------------------------------------------------------------- n:= 10 aData := { "Number", 38, "aRGB", YELLOW, "Hello" } // cMsg := MsgDebug ( TIME(), aData, {|| NIL}, .F., EVAL({|| DATE ()}), n == 3 ) aRows := ARRAY (20) aRows [1] := {'Simpson', 'Homer', '555-5555', 1, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [2] := {'Mulder', 'Fox', '324-6432', 2, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [3] := {'Smart', 'Max', '432-5892', 3, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [4] := {'Grillo', 'Pepe', '894-2332', 4, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [5] := {'Kirk', 'James', '346-9873', 5, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [6] := {'Barriga', 'Carlos', '394-9654', 6, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [7] := {'Flanders', 'Ned', '435-3211', 7, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [8] := {'Smith', 'John', '123-1234', 8, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [9] := {'Pedemonti', 'Flavio', '000-0000', 9, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [10] := {'Gomez', 'Juan', '583-4832', 10, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [11] := {'Fernandez', 'Raul', '321-4332', 11, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [12] := {'Borges', 'Javier', '326-9430', 12, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [13] := {'Alvarez', 'Alberto', '543-7898', 13, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [14] := {'Gonzalez', 'Ambo', '437-8473', 14, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [15] := {'Batistuta', 'Gol', '485-2843', 15, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [16] := {'Vinazzi', 'Amigo', '394-5983', 16, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [17] := {'Pedemonti', 'Flavio', '534-7984', 17, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [18] := {'Samarbide', 'Armando', '854-7873', 18, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [19] := {'Pradon', 'Alejandra', '???-????', 19, HMG_TimeToTime( TIME(), _TIMESHORT12H )} aRows [20] := {'Reyes', 'Monica', '432-5836', 20, HMG_TimeToTime( TIME(), _TIMESHORT12H )} //bColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , {128,128,128} , {192,192,192} ) } //fColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , BLUE , RED ) } // CellNavigationColor (_SELECTEDCELL_FORECOLOR, BROWN) //CellNavigationColor (_SELECTEDCELL_BACKCOLOR, GREEN) // CellNavigationColor (_SELECTEDCELL_DISPLAYCOLOR, .T.) // CellNavigationColor (_SELECTEDROW_FORECOLOR, YELLOW) // CellNavigationColor (_SELECTEDROW_BACKCOLOR, BROWN) // CellNavigationColor (_SELECTEDROW_DISPLAYCOLOR, .T.) /* Form_1.Grid_1.ColumnHEADER (1) := "--- Last Name ---" Form_1.Grid_1.ColumnWIDTH (1) := 100 Form_1.Grid_1.ColumnJUSTIFY (1) := GRID_JTFY_CENTER Form_1.Grid_1.ColumnCONTROL (1) := {'TEXTBOX','CHARACTER','@!'} Form_1.Grid_1.ColumnDYNAMICFORECOLOR (1) := {|| BLACK} Form_1.Grid_1.ColumnDYNAMICBACKCOLOR (1) := {|| PURPLE} Form_1.Grid_1.ColumnVALID (1) := {|| NIL} Form_1.Grid_1.ColumnWHEN (1) := {|| NIL} Form_1.Grid_1.ColumnONHEADCLICK (1) := {|| MsgInfo (Form_1.Grid_1.ColumnHEADER(1))} Form_1.Grid_1.ColumnONHEADCLICK (3) := {|| Form_1.Grid_1.ColumnWIDTH (3) := GRID_WIDTH_AUTOSIZEHEADER} Form_1.Grid_1.ColumnONHEADCLICK (5) := {|| Form_1.Grid_1.ColumnWIDTH (5) := GRID_WIDTH_AUTOSIZE} */ Load Window Fomr_1 FOR i=1 TO 20 Fomr_1.Grid_1.AddItem ( {'lolo','JUAN','333-9999', 21, HMG_TimeToTime(TIME(),_TIMESHORT12H)} ) // Added this item in the END of the GRID Fomr_1.Grid_1.AddItemEx ( {'Lolo','LOLO','333-9999', 22, HMG_TimeToTime(TIME(),_TIMESHORT12H)}, NIL ) // Added this item in the END of the GRID Fomr_1.Grid_1.AddItemEx ( {'hmg', 'JUAN','333-9999', 23, HMG_TimeToTime(TIME(),_TIMESHORT12H)}, 3 ) // Added this item in Row 3 NEXT Fomr_1.Center Fomr_1.Activate Return function cor() bColor := { || if( This.CellRowIndex/2 == int(This.CellRowIndex/2), BLUE , RED ) } //bColor := { || RED } //DoMethod( 'Fomr_1', "Grid_1", "Refresh", .T. ) return #endif