1. EuGrid: Coloring Rows by Row Data

I'd like to color the rows of a EuGrid control according to data found in the row. For example, if column 1 contains a "1," then color is Green. If column 1 contains a "0," then color is Yellow.

I've tried intercepting a w32HEvent for the EuGrid, then acting on the EGW_CELLFORMAT message, but I can't figure it out.

Anybody know of or have a way to do this?

new topic     » topic index » view message » categorize

2. Re: EuGrid: Coloring Rows by Row Data

Hi,

Hope this is useful.

--*------------------------------------------------------* 
-- onGrid134Event: Event handler for grid134 
--*------------------------------------------------------* 
procedure onGrid134Event (atom self, atom event, sequence parms) 
	atom msg, wParam, lParam, row, col 
	object rowdata 
 
	msg = parms[1] 
	wParam = parms[2] 
	lParam = parms[3] 
 
	-- Set attributes for individual cells as they are drawn 
	if msg=EGW_CELLFORMAT then 
 
		-- Get row and column information 
		row = EGW_GetCellProperty(self, wParam, EGW_CELL_ROW) 
		col = EGW_GetCellProperty(self, wParam, EGW_CELL_COL_ID) 
		 
		-- Set cell properties according to data held in the row col 9 (status) 
		if row>0 
			-- and col=grid7col2 
			then 
 
			-- Get data for row 
				rowdata = EGW_GetDataRow(self, row) 
 
			if sequence(rowdata) then 
				if find(rowdata[9], {"Cancelled", "Expired"}) then -- Expired Reg. Key 
 
					if not (col = EuGrid134col3) then -- other than Reg. Key Column 
 
						if (col = EuGrid134col9) then -- Status Column 
							-- Set cell background color 
							void = EGW_SetCellProperty(self, wParam, EGW_CELL_BACKGROUND_COLOR, White) 
							if equal(rowdata[9], "Cancelled") then 
								void = EGW_SetCellProperty(self, wParam, EGW_CELL_TEXT_COLOR, BrightBlue) 
							else 
								void = EGW_SetCellProperty(self, wParam, EGW_CELL_TEXT_COLOR, BrightRed) 
							end if 
						end if 
 
					else -- Reg. Key Column 
						-- Set cell font 
						void = EGW_SetCellProperty(self, wParam, EGW_CELL_FONT, hFontVERx) 
 
						-- Set cell background color 
						void = EGW_SetCellProperty(self, wParam, EGW_CELL_BACKGROUND_COLOR, White) 
						-- Set cell text color 
						if equal(rowdata[9], "Cancelled") then 
							void = EGW_SetCellProperty(self, wParam, EGW_CELL_TEXT_COLOR, BrightBlue) 
						else 
							void = EGW_SetCellProperty(self, wParam, EGW_CELL_TEXT_COLOR, BrightRed) 
						end if 
 
					end if 
				else -- other than Expired Reg. Key 
 
					if equal(rowdata[9], "Active") then -- Active Reg. Key 
						-- Set cell font 
						void = EGW_SetCellProperty(self, wParam, EGW_CELL_FONT, hFontVERb) 
 
						if (col = EuGrid134col3) -- Reg. Key Column 
							or (col = EuGrid134col9) -- Status Column 
							then 
							-- Set cell background color 
							void = EGW_SetCellProperty(self, wParam, EGW_CELL_BACKGROUND_COLOR, Yellow) 
							-- Set cell text color 
							void = EGW_SetCellProperty(self, wParam, EGW_CELL_TEXT_COLOR, Black) 
						end if 
					end if 
 
				end if 
			end if 
		end if 
	end if 
end procedure 
setHandler(EuGrid134, w32HEvent, routine_id("onGrid134Event")) 


Regards,
Rad.

new topic     » goto parent     » topic index » view message » categorize

3. Re: EuGrid: Coloring Rows by Row Data

Rad said...

Hope this is useful.

Rad, that did it! Thanks so much! :)

new topic     » goto parent     » topic index » view message » categorize

4. Re: EuGrid: Coloring Rows by Row Data

Glad to help. I had asked this query some time back and one of the Euphorians had helped out.

Though I have a Q.

I am using Eu3.1.1 + Win32Lib 0.70.19 + Judith's IDE on WinXP Pro SP2.

Sometimes when I load this program with colored EuGrid, the "strike-out" does not work. But same program works when reloaded again. This error occurs randomly. Have you encountered anything like this?

I am not sure whether the problem lies with the IDE, Win32Lib, or the code itself.

Regards,
Rad.

new topic     » goto parent     » topic index » view message » categorize

5. Re: EuGrid: Coloring Rows by Row Data

Rad said...

I am using Eu3.1.1 + Win32Lib 0.70.19 + Judith's IDE on WinXP Pro SP2.

Sometimes when I load this program with colored EuGrid, the "strike-out" does not work. But same program works when reloaded again. This error occurs randomly. Have you encountered anything like this?

No, I have not. But I probably don't use the grid control as extensively as you. :/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu