color in cell and color in a grid line

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
andyglezl
Posts: 1061
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 24 times
Been thanked: 48 times
Contact:

Re: color in cell and color in a grid line

Post by andyglezl » Sun Jul 22, 2018 3:33 am

If you put the following when adding

DoMethod( 'Form_Grid', "Grid_1", "Refresh", .T. )
Andrés González López
Desde Guadalajara, Jalisco. México.

martingz
Posts: 248
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico
Has thanked: 12 times
Been thanked: 9 times

Post by martingz » Sun Jul 22, 2018 4:05 pm

Jairpinho, I hope I have understood what you ned

i used this

aColCan:={ ||if( From_1.Grid_TELROL.Cell(This.CellRowIndex,4) == '+', AQUAMARIN, MISTYROSE ) }

@ 10,160 GRID Grid_TELROL ;
WIDTH 600;
HEIGHT 760 ;
HEADERS {'Days', "Inputtime", 'SubTotal', '*', 'Seconds'};
WIDTHS { 50, 165, 165, 40, 180 };
JUSTIFY { GRID_JTFY_RIGHT, GRID_JTFY_LEFT , GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_RIGHT } ;
FONT "Arial" SIZE 24;
DYNAMICBACKCOLOR { aColCan, aColCan, aColCan, aColCan ,aColCan }

User avatar
jairpinho
Posts: 252
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Sun Jul 22, 2018 5:32 pm

I created a project, I need to do it this way with the push of a button
grid2.zip
(1.46 MiB) Downloaded 23 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
andyglezl
Posts: 1061
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 24 times
Been thanked: 48 times
Contact:

Post by andyglezl » Sun Jul 22, 2018 7:58 pm

Yo sigo sin entender...
-----------------------------
I still dont get it...
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.
Quizá quisiste decir "Color" en vez de "Valor" ???
-----------------------------------------------------------
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
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
jairpinho
Posts: 252
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Sun Jul 22, 2018 8:23 pm

andyglezl wrote:
Sun Jul 22, 2018 7:58 pm
Yo sigo sin entender...
-----------------------------
I still dont get it...
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.
Quizá quisiste decir "Color" en vez de "Valor" ???
-----------------------------------------------------------
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

Quizá quisiste decir "Color" en vez de "Valor" sim color
-----------------------------------------------------------
Maybe you wanted to say "Color" instead of "Value" yes color
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
andyglezl
Posts: 1061
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 24 times
Been thanked: 48 times
Contact:

Post by andyglezl » Mon Jul 23, 2018 3:00 am

Quizá de esta forma te sirva...
--------------------------------------
Maybe in this way it will serve you ...

grid2.rar
(2.09 KiB) Downloaded 27 times
gridx.png
gridx.png (18.23 KiB) Viewed 399 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
jairpinho
Posts: 252
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Mon Jul 23, 2018 10:11 am

andyglezl wrote:
Mon Jul 23, 2018 3:00 am
Quizá de esta forma te sirva...
--------------------------------------
Maybe in this way it will serve you ...


grid2.rar

gridx.png
the file does not decompress
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

edk
Posts: 385
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 114 times
Been thanked: 286 times

Post by edk » Mon Jul 23, 2018 11:23 am

And here is my variation on the change of colors in Grid. I used my "color map" to be able to color specific cells, rows and columns regardless of their value.
I hope it will be helpful.
Bez tytułu.png
Bez tytułu.png (17.82 KiB) Viewed 373 times
grid2.7z
(2.91 KiB) Downloaded 43 times

User avatar
jairpinho
Posts: 252
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Tue Jul 24, 2018 10:53 am

edk wrote:
Mon Jul 23, 2018 11:23 am
And here is my variation on the change of colors in Grid. I used my "color map" to be able to color specific cells, rows and columns regardless of their value.
I hope it will be helpful.
Bez tytułu.png
grid2.7z

thanks edk what I need, there is another easier way to do or just like in the example, I changed the project.
GRID2C.zip
(4.05 KiB) Downloaded 31 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
andyglezl
Posts: 1061
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 24 times
Been thanked: 48 times
Contact:

Post by andyglezl » Thu Jul 26, 2018 2:37 pm

Hola Edward

Gracias por tu Excelente ejemplo, estoy experimentando con el,
pero tengo algunas dudas...

* Cuando al llenar una columna de algun color me queda OK, y si la borro (Nil) tambien queda OK.
pero cuando lleno con colores diferentes esa misma columna y la quiero borrar, sigue dejando los
mismos colores ??

* Lo mismo pasa cuando quiero borrar un renglon.

* Cuando quiero borrar todo el grid me queda OK con lo suçiguiente:

For i1=1 TO 8
Form_1.Grid_1.ColumnDYNAMICBACKCOLOR(i1) := WHITE
NEXT
bColorMap := {}
pero cuando es por columna o renglon, no que elementos de bColorMap borrar.

* Será posible que se pueda guardar ese Grid con los colores que tiene y volverlo a cargar otra ves ??
---------------------------------------------------------------------------------------------------------------------------------

Hello Edward

Thanks for your Excellent example, I'm experimenting with it,
but I have some doubts ...

* When filling a column of some color I have OK, and if I delete (Nil) is also OK.
but when I fill that same column with different colors and I want to erase it, it still leaves the
same colors ??

* The same happens when I want to delete a line.

* When I want to delete the entire grid, I'm OK with the following:

For i1 = 1 TO 8
Form_1.Grid_1.ColumnDYNAMICBACKCOLOR (i1): = WHITE
NEXT
bColorMap: = {}
but when it is by column or row, I do not know what elements of bColorMap to erase.

* Will it be possible to save that Grid with the colors it has and reload it again ??

Gracias por tu tiempo
---------------------------
Thanks for your time
gridcolor.png
gridcolor.png (20.39 KiB) Viewed 272 times
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply