To do this, you'd have to do quite of bit of extending of the datagrid and
override some of the draw events to achieve the desired results. When I
looked at the amount of time it would take I ended up buying Infragistics
..NET Advantage 3.0. I downloaded & installed it (5min), and used their
UltraGrid, which has quite a few of these features available during design
time.
I got everything I wanted in about an hour, which included much more complex
logic than you seem to need. As a brief example, I had a cell that I wanted
to color blue of cell 3 and cell 7 if they both equalled "yes". I simply
utilized the Initialize_Row event, which passes in RowEventArgs for each row
as it it retrieved from your datasource and/or class.
From there I could just
/**/
if (e.Row.Cells["ColName3"].Value == "Yes" &&
e.Row.Cells["ColName7"].Value == "Yes")
{
e.Row.Cells["MyCellToHightlightColName"].CellAppearance.BackColor =
System.Drawing.Color.Blue;
}
/**/
or something to that effect.
Hope this helps!
Nick Harris, MCP, CNA, MCSD
Director of Software Services
http://www.VizSoft.net
"DraguVaso" <(E-Mail Removed)> wrote in message
news:3fdf2716$0$16026$(E-Mail Removed)...
> Hi,
>
> I'm looking for a nice way to format the cell of my datagrid according to
> some predefined 'rules'. I found a lot on the site of George shepherd, but
> it wasn't really what I was looking for:
>
> I found there: How can I change the font used in a Gridcell on a cell by
> cell or row by row basis. Wih this code I am able to change the
> Font/Background/... based on the position of the field (column and row).
The
> problem is: it only changes the font etc, and not the format of it.
> http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q927q
>
> Another usefull thing: How can I perform custom formatting on the cells in
> my datagrid: This changes the format of a cell: like "1234" becomes
"12-34"
> and stuff like that.
> http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q881q
>
> BUT (and now it comes): I'm not able to make something liek a 'merge' of
> these two things. What I actually need is being able to change Font,
> Backgroundcolor, Format, etc based on the entire row!!
>
> For example: If the value in one field is zero, another Field has to get
> marked in a specific Color (in the same record offcourse).
>
> Anybody got any idea? Or better: A nice working example, or somewhere a
> Class that takes care for all this stuff.
>
> Thanks a lot in advance!
>
> Pieter
>
>
>
>
>
>
>
>