DynamicColor of one Column depending on other Column

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

DynamicColor of one Column depending on other Column

Post by sudip »

Hello Friends,

This is the smallest and the simplest project I want to share with you ;) . But, forgive me, I can't just resist myself to share the very simple solution I got (thinking 3/4 days :o :lol: ), with you :)

I forgot to mention, this small sample was created from tips by Master Roberto Lopez. Thank you master :)

I want to change DynamicForeColor of a Column of a Grid depending on the value of another column of the same grid.
DynColor.jpg
DynColor.jpg (29.3 KiB) Viewed 3433 times
Here is the source code
DynamicColor.zip
(2.48 KiB) Downloaded 384 times
With best regards.

Sudip
Last edited by sudip on Thu Jan 14, 2010 5:15 pm, edited 1 time in total.
With best regards,
Sudip
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DynamicColor of one Column depending on other Column

Post by Rathinagiri »

Hi Sudip,

Thanks for sharing. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: DynamicColor of one Column depending on other Column

Post by Roberto Lopez »

sudip wrote:Hello Friends,

This is the smallest and the simplest project I want to share with you ;) . But, forgive me, I can't just resist myself to share the very simple solution I got (thinking 3/4 days :o :lol: ), with you :)

I want to change DynamicForeColor of a Column of a Grid depending on the value of another column of the same grid.
DynColor.jpg
Here is the source code
DynamicColor.zip
With best regards.

Sudip
If you are trying to change the forecolor for column 2 based on column 2 content:

Please, replace your DynColor function with this:

Code: Select all

Function DynColor(mRow, mCol)
local r

	if mCol == 2 

		if frmAtten.grdAtten.cell(mRow, 2) = 1

			r := {0, 0, 0}

		else

			r := {0, 255, 0}

		endif

	else

		r := {0, 0, 0}		

	endif

return r

If you are trying to change the forecolor for column 1 based on column 2 content:

Please, replace your DynColor function with this:

Code: Select all

Function DynColor(mRow, mCol)
local r

	if mCol == 1

		if frmAtten.grdAtten.cell(mRow, 2) = 1

			r := {0, 0, 0}

		else

			r := {0, 255, 0}

		endif

	else

		r := {0, 0, 0}		

	endif

return r

Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: DynamicColor of one Column depending on other Column

Post by sudip »

Hello Master Roberto,

Thanks a lot for checking this small sample and for your tips :)
My original sample was also built on your tips :)

Thank you again.

Rahi, it's the beauty of HMGForum that creator of very small things (like me), also encouraged to do better :) Thank you :)

If someone asks me what is the best thing of Clipper and Harbour, I will say, "Code Block". But, unfortunately I am not very easy with it ;)

With best regards.

Sudip
With best regards,
Sudip
Post Reply