Color of highlight bar in GRID and BROWSE control

Source code related resources

Moderator: Rathinagiri

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

Color of highlight bar in GRID and BROWSE control

Post by mol »

Hi guys!
I want to realize project when highlight bar in BROWSE (still used with .dbf files by me) and GRID will change color from default (it's BLUE in my windows).
It will be used with incremental search - when record with exact match is found - color changes to green, in another case - record is highlighted in RED.

first solution for grid was presented by Grigory Filatov (in STRU theme), but it doesn't work with BROWSE and it's not dynamical.
Have you any solution for this problem?
Regards, Marek

PS. Grigory code below for refresh memory ;)
gfilatov wrote:
Pablo César wrote:One question: Is it possible in HMG to change color of highlighted row in grid component ?
It is possible with changing of the following internal variables:
* _HMG_SYSDATA [ 348 ] -> Grid Selected Row ForeColor (by cell navigation)
* _HMG_SYSDATA [ 349 ] -> Grid Selected Row BackColor (by cell navigation)
The working sample is below:

Code: Select all

/*
* HMG Grid Demo
* (c) 2005 Roberto Lopez
*/

#include "hmg.ch"

Function Main

Local aRows [20] [3]

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 ;
		HEIGHT 400 ;
		TITLE 'Mixed Data Type Grid Test' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Set Item'	ACTION SetItem()
				MENUITEM 'Get Item'	ACTION GetItem()
			END POPUP
		END MENU

		aRows [1]	:= {113.12,date(),1,1 , .t. }
		aRows [2]	:= {123.12,date(),2,2 , .f. } 
		aRows [3]	:= {133.12,date(),3,3, .t. } 
		aRows [4]	:= {143.12,date(),1,4, .f. } 
		aRows [5]	:= {153.12,date(),2,5, .t. } 
		aRows [6]	:= {163.12,date(),3,6, .f. } 
		aRows [7]	:= {173.12,date(),1,7, .t. } 
		aRows [8]	:= {183.12,date(),2,8, .f. } 
		aRows [9]	:= {193.12,date(),3,9, .t. } 
		aRows [10]	:= {113.12,date(),1,10, .f. } 
		aRows [11]	:= {123.12,date(),2,11, .t. } 
		aRows [12]	:= {133.12,date(),3,12, .f. } 
		aRows [13]	:= {143.12,date(),1,13, .t. } 
		aRows [14]	:= {153.12,date(),2,14, .f. } 
		aRows [15]	:= {163.12,date(),3,15, .t. } 
		aRows [16]	:= {173.12,date(),1,16, .f. } 
		aRows [17]	:= {183.12,date(),2,17, .t. } 
		aRows [18]	:= {193.12,date(),3,18, .f. } 
		aRows [19]	:= {113.12,date(),1,19, .t. } 
		aRows [20]	:= {123.12,date(),2,20, .f. } 

_HMG_SYSDATA [ 348 ] := YELLOW
_HMG_SYSDATA [ 349 ] := RED
_HMG_SYSDATA [ 350 ] := YELLOW
_HMG_SYSDATA [ 351 ] := RED

		@ 10,10 GRID Grid_1 ;
		WIDTH 620 ;
		HEIGHT 330 ;
		HEADERS {'Column 1','Column 2','Column 3','Column 4','Column 5'} ;
		WIDTHS {140,140,140,140,140} ;
		ITEMS aRows ;
		EDIT ON CHANGE playbeep() ;
		COLUMNCONTROLS { {'TEXTBOX','NUMERIC','$ 999,999.99'} , {'DATEPICKER','DROPDOWN'} , {'COMBOBOX',{'One','Two','Three'}} , { 'SPINNER' , 1 , 20 } , { 'CHECKBOX' , 'Yes' , 'No' } } ;
		CELLNAVIGATION

	END WINDOW

Form_1.Grid_1.Value := { 1, 1 }

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return

PROCEDURE SETITEM()

	Form_1.Grid_1.Item (2) := { 123.45 , date() , 2 , 10 , .T. }

RETURN

PROCEDURE GETITEM()
local a

	a := Form_1.Grid_1.Item (2) 

	msginfo ( str ( a [1] )				, '1' )
	msginfo ( dtoc ( a [2] )			, '2' )
	msginfo ( str( a [3] )				, '3' )
	msginfo ( str ( a [4] )				, '4' )
	msginfo ( if ( a [5] == .t. , '.t.' , '.f.' )	, '5' )

RETURN
Hope that helps. :idea:
User avatar
Agil Abdullah
Posts: 204
Joined: Mon Aug 25, 2014 11:57 am
Location: Jakarta, Indonesia
Contact:

Re: Color of highlight bar in GRID and BROWSE control

Post by Agil Abdullah »

Hi Marek,

As long as your proposal drives us to more interesting/impressive look on the grid field, be my guest. I will be glad to.

Cheers.
Agil Abdullah Albatati (just call me Agil)
Programmer Never Surrender
User avatar
Agil Abdullah
Posts: 204
Joined: Mon Aug 25, 2014 11:57 am
Location: Jakarta, Indonesia
Contact:

Re: Color of highlight bar in GRID and BROWSE control

Post by Agil Abdullah »

I tried to compile your code, but I found it irritating to my eyes. Combination of Yellow on Red looks bad. I think it's better to change to Blue on Gray. So your code should change (if you agree) to below and see what you feel: :)

Code:

_HMG_SYSDATA [ 348 ] := BLUE
_HMG_SYSDATA [ 349 ] := GRAY
_HMG_SYSDATA [ 350 ] := BLUE
_HMG_SYSDATA [ 351 ] := GRAY


Cheers...
Agil Abdullah Albatati (just call me Agil)
Programmer Never Surrender
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Color of highlight bar in GRID and BROWSE control

Post by mol »

This code was plased by Grigory Filatov. I've only remained this solution...
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Color of highlight bar in GRID and BROWSE control

Post by Javier Tovar »

Gracias Mol por la información!

Saludos
User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium

Re: Color of highlight bar in GRID and BROWSE control

Post by Clip2Mania »

but it doesn't work with BROWSE and it's not dynamical.
Have you any solution for this problem?
Looked @ the source code and I don't see an immediate workaround/solution.
Would like something like this too.
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Color of highlight bar in GRID and BROWSE control

Post by Amarante »

Hi,
Anyone know how I can do the same without CELLNAVIGATION clause?
Post Reply