473,326 Members | 2,133 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,326 software developers and data experts.

Changing the Color of a Row in a Datagrid

C# WinForms

I am trying to find a good solution for changing the color of a row in a
datagrid, at runtime, based on the contents of a certain cell of the row, or
a related value in the database. I cant believe it is as hard as I am
finding. This is surely a common problem.

All the solutions I have found so far though, seem very specific, and that
if I want this in various datagrids through my application I will have to
have a load of custom DataGridTextColumns with Paint overrided.

I have a custom Datagrid object which has in it various custom methods and
properties that I want all my datagrids to have, so ideally I want to put
this row colour function in there, or in a similar high up object so I dont
have to keep creating custom column styles. Has anyone done anything like
this before or does everyone just keep overriding the column style??

Thanks

Ste
Apr 20 '06 #1
1 1484

One more thing. I see that in WebForms you can hook into the row through
the ItemDataBound event. Is there not an equivalent entry point for
WinForms??

"Steve" wrote:
C# WinForms

I am trying to find a good solution for changing the color of a row in a
datagrid, at runtime, based on the contents of a certain cell of the row, or
a related value in the database. I cant believe it is as hard as I am
finding. This is surely a common problem.

All the solutions I have found so far though, seem very specific, and that
if I want this in various datagrids through my application I will have to
have a load of custom DataGridTextColumns with Paint overrided.

I have a custom Datagrid object which has in it various custom methods and
properties that I want all my datagrids to have, so ideally I want to put
this row colour function in there, or in a similar high up object so I dont
have to keep creating custom column styles. Has anyone done anything like
this before or does everyone just keep overriding the column style??

Thanks

Ste

Apr 20 '06 #2

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

Similar topics

3
by: mvargasp | last post by:
Hi all, I have a web form which contains a frame, (a form containing a menu on the left and a web form containing a datagrid on the right). Also there is a button (right side) which transforms...
1
by: Amos | last post by:
Can I add a column to the datagrid and also resize it? I add them like this: DataTableAddress.Columns.Add("Col1", typeof(string)); DataTableAddress.Columns.Add("Col2", typeof(string));...
1
by: Shawn Benson | last post by:
I have a Windows form where a user enters an order number which returns a dataset that is bound to a datagrid. The problem is when a user clicks on a cell in the datagrid, then enters another...
3
by: Doug | last post by:
Hi I have the following code (not mine) that populates a datagrid with some file names. But I want to replace the datagrid with a combo box. private void OnCurrentDataCellChanged(object sender,...
1
by: Simon Harris | last post by:
Hi All, Ok, I have 6 datagrids, populated from 1 dataset. Each datagrid has 3 columns. There are 18 columns in the dataset. I have written a sub to change the background colour of the row in...
2
by: david | last post by:
Problem: There is a search button, Search, in form, for searching patient info list. The error occurs after the following steps: 1. search first time is OK, and all found the records are...
1
by: Anup | last post by:
Hi group, I m using protected System.Web.UI.WebControls.DataGrid (ASP.NET 1.x) I have set the "pager style mode" to "NumericPages" with "AllowingPaging=true"
1
by: Veeves | last post by:
I would like to change the width of a datagrid column at run time. I have noticed when creating a datagrid, if the header text is shorter than the data in the column, then the column width set by...
1
by: Blasting Cap | last post by:
I am having trouble changing the font for a PushButton control in a datagrid button column. I have seen several posts refer to styles and simple changes to the HTML for font changes but most of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.