473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Build a multi-coloured Data bound Grid.

Hi all

I am currently using a Bound Read Only data grid.

What I am looking to do is have different colour rows depending on the data
in the row.

EG. If the status = Closed then that row should be Red, If the Status = Open
then That row should be Green.

I am trying not to loop through all the rows setting the Back colour of each
row or I may as well not bother binding the grid.

Any ideas?

Thanks.
ink
Mar 19 '07 #1
4 2947
If this is a DataGridView, then you could try handling the RowPrePaint
event and there conditionally set the BackColor.

void dataGridView1_RowPrePaint(object sender,
DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex == 1)
dataGridView1.Rows[1].DefaultCellStyle.BackColor =
Color.Red;
else if(e.RowIndex == 3)
dataGridView1.Rows[3].DefaultCellStyle.BackColor =
Color.Blue;
}
==================
Clay Burch
Syncfusion, Inc.

Mar 19 '07 #2
Thanks for the advice Clay.

i will give this a try.


"ClayB" <cl***@syncfusion.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
If this is a DataGridView, then you could try handling the RowPrePaint
event and there conditionally set the BackColor.

void dataGridView1_RowPrePaint(object sender,
DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex == 1)
dataGridView1.Rows[1].DefaultCellStyle.BackColor =
Color.Red;
else if(e.RowIndex == 3)
dataGridView1.Rows[3].DefaultCellStyle.BackColor =
Color.Blue;
}
==================
Clay Burch
Syncfusion, Inc.

Mar 19 '07 #3
THis document has a lot of anwers to questions liek yours:

http://www.windowsforms.net/Samples/...View%20FAQ.doc

It is GREAT!
"iKiLL" wrote:
Thanks for the advice Clay.

i will give this a try.


"ClayB" <cl***@syncfusion.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
If this is a DataGridView, then you could try handling the RowPrePaint
event and there conditionally set the BackColor.

void dataGridView1_RowPrePaint(object sender,
DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex == 1)
dataGridView1.Rows[1].DefaultCellStyle.BackColor =
Color.Red;
else if(e.RowIndex == 3)
dataGridView1.Rows[3].DefaultCellStyle.BackColor =
Color.Blue;
}
==================
Clay Burch
Syncfusion, Inc.


Mar 19 '07 #4
Thanks Chris

i will take a look

"Chris" <Ch***@discussions.microsoft.comwrote in message
news:E7**********************************@microsof t.com...
THis document has a lot of anwers to questions liek yours:

http://www.windowsforms.net/Samples/...View%20FAQ.doc

It is GREAT!
"iKiLL" wrote:
>Thanks for the advice Clay.

i will give this a try.


"ClayB" <cl***@syncfusion.comwrote in message
news:11*********************@l77g2000hsb.googlegr oups.com...
If this is a DataGridView, then you could try handling the RowPrePaint
event and there conditionally set the BackColor.

void dataGridView1_RowPrePaint(object sender,
DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex == 1)
dataGridView1.Rows[1].DefaultCellStyle.BackColor =
Color.Red;
else if(e.RowIndex == 3)
dataGridView1.Rows[3].DefaultCellStyle.BackColor =
Color.Blue;
}
==================
Clay Burch
Syncfusion, Inc.



Mar 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: arifvahora | last post by:
Active Server Pages error 'ASP 0240' Script Engine Exception work.asp A ScriptEngine threw exception 'C0000005' in 'IActiveScript::SetScriptState()' from...
2
by: Daric | last post by:
Hi, al I'm using VS2002 to create my web application, by default, VS2002 will build my project in a single dll (myWebApp.dll), but I hope each page correspond to it's own dll (page1.dll, page2.dll),...
2
by: | last post by:
I have not been able to see any difference between what happens when I use Build>Build Solution or Build>ReBuild Solution. Is there any reason to use one or the other at any time? Thanx......joisey
8
by: Pavel A. | last post by:
Can anybody shed some light... Confused here :(( Isn't VS.2005 supposed to use the new build system, that can be invoked separately from the IDE? If yes, why it creates vcproj files? Are these...
10
by: Larry Hastings | last post by:
I'm an indie shareware Windows game developer. In indie shareware game development, download size is terribly important; conventional wisdom holds that--even today--your download should be 5MB or...
1
by: Mike | last post by:
Hi, I'm a complete newbie to XML and am needing to rush through a job requiring far more knowledge than I have the time to gather. Basically... I need to build a breadcrumb menu for our...
3
by: michael.lang | last post by:
I am using PostBuild events in a C# project to run some tasks, but only when in release configuration mode. The build events run perfectly as expected when run. The problem comes when I save the...
5
by: maggie.nguyen | last post by:
Hi, I use Visual Studios 2005. In my project file, I include the library in linker: "Additional Library Directories: ..\..\boost\lib" I have these libs in the boost\lib directory: ...
0
by: anupamak | last post by:
hello, I created a win32 project(precompiled headers, console application). This was created to create a service( for which i used SERVICE_TABLE_ENTRY, SERVICE_STATUS, SERVICE_STATUS_HANDLE,...
14
by: yxq | last post by:
Hello, I want to build the multi-language application with the xml file, how to do? could anyone tell a sample? Thank you
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.