dynamicbackcolor in grid, how?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

dynamicbackcolor in grid, how?

Post by dragancesu »

the program reads mysql and writes to the grid

how to define a DYNAMICBACKCOLOR to coloring rows, like residents > 15,000,000

how referenced this field for examine

thank you

p.s. in config.ini is connection setting, just edit with notepad/notepad++ or same
Attachments
grid.zip
(16.89 KiB) Downloaded 194 times
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: dynamicbackcolor in grid, how?

Post by serge_girard »

Hello Dragan,

I use this construction:

Code: Select all

Grid:
      DYNAMICBACKCOLOR  { { || BC_Grid_1()},{||BC_Grid_1()},{||BC_Grid_1()},{||BC_Grid_1()},{||BC_Grid_1()} }  // each column needs a call to  BC_Grid_1()



FUNCTION BC_Grid_1()
/**************************/
LOCAL a
LOCAL aColors  := {{ WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE,  ;
                     WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE,  ;
                     WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE,  ;
                     WHITE ,WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE } }  // EQUAL TO NUMBER OF COLUMNS == 32
LOCAL aItem    := Form_1.Grid_1.Item ( This.CellRowIndex ) 

IF aItem [30] == 'X' 
   FOR a = 1 TO 32
      aColors [1] [a] := MISTYROSE   
   NEXT a
ENDIF

 
IF aItem [31] == '=' 
   FOR a = 1 TO 32
      aColors [1] [a] := LAVENDER   
   NEXT a
ENDIF
 


IF val(aItem [32]) > 0 // GROUP
   FOR a = 1 TO 32
      aColors [1] [a] := HONEYDEW   
   NEXT a
ENDIF
 
RETURN aColors [1] [ This.CellColIndex ]
In BC_Grid_1() you can place any kind of condition in order to color any field.

Greetings, Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: dynamicbackcolor in grid, how?

Post by serge_girard »

Dragan,

I made a change in your mysqlfn.prg in order to get it working:

Code: Select all

If AScan( aDatabaseList, (_Database) ) == 0  // removed  Lower !!!!
  MsgINFO( "Database " + _Database + " doesn't exist!")
  Return Nil
EndIf 


There's nothing you can do that can't be done...
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: dynamicbackcolor in grid, how?

Post by dragancesu »

Thank you Serge
Post Reply