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: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

DynamicColor of one Column depending on other Column

Post by sudip » Thu Jan 14, 2010 3:11 pm

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 944 times
Here is the source code
DynamicColor.zip
(2.48 KiB) Downloaded 162 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: 5172
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 136 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Thu Jan 14, 2010 4:15 pm

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: 3900
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 136 times

Post by Roberto Lopez » Thu Jan 14, 2010 4:20 pm

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: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Thu Jan 14, 2010 5:13 pm

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