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

red cells in DataGrid

I have DataGrid linked to a data table. I want to be able to show particular
column in different color, depending on some other column values in the same
line.
Any ideas how to do this?
Thank you
Nov 16 '05 #1
5 1262
Hi Alex,

You can use the DataGrid's ItemCreated event and use the members of the
DataGridItemEventArgs to get to the columns of the row being evaluated.

http://msdn.microsoft.com/library/de...classtopic.asp

Joe
--
http://www.csharp-station.com

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
I have DataGrid linked to a data table. I want to be able to show particular column in different color, depending on some other column values in the same line.
Any ideas how to do this?
Thank you

Nov 16 '05 #2
Hi Alex,

Just to add on to what Joe said; if you are rather trying to notify the user
on errors in a column , you could use the DataRow.SetColumnError method.

HTH,
- Rakesh Rajan

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
I have DataGrid linked to a data table. I want to be able to show particular column in different color, depending on some other column values in the same line.
Any ideas how to do this?
Thank you

Nov 16 '05 #3
there is no such event in System.Windows.Forms.
It is only defined in Web.UI.WebControls ...
"Joe Mayo" wrote:
Hi Alex,

You can use the DataGrid's ItemCreated event and use the members of the
DataGridItemEventArgs to get to the columns of the row being evaluated.

http://msdn.microsoft.com/library/de...classtopic.asp

Joe
--
http://www.csharp-station.com

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
I have DataGrid linked to a data table. I want to be able to show

particular
column in different color, depending on some other column values in the

same
line.
Any ideas how to do this?
Thank you


Nov 16 '05 #4
The Syncfusion Windows Forms FAQ is pretty helpful with figuring a lot of
things out. Sometimes you can find FAQs that are very similar to what you
want to do and put the pieces together. i.e. This one may help get you
started:

http://www.syncfusion.com/faq/winforms/search/745.asp

Joe
--
http://www.csharp-station.com

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
there is no such event in System.Windows.Forms.
It is only defined in Web.UI.WebControls ...
"Joe Mayo" wrote:
Hi Alex,

You can use the DataGrid's ItemCreated event and use the members of the
DataGridItemEventArgs to get to the columns of the row being evaluated.

http://msdn.microsoft.com/library/de...classtopic.asp
Joe
--
http://www.csharp-station.com

"Alex K." <Al***@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
I have DataGrid linked to a data table. I want to be able to show

particular
column in different color, depending on some other column values in
the same
line.
Any ideas how to do this?
Thank you


Nov 16 '05 #5
Hi Alex,

To supply a different color for a column or cell, you could derive a class
from System.Windows.Forms.DataGridTextBoxColumn, override its Paint method
(the one with 7 parameters) and supply your own colors. Paint method takes a
backBrush and foreBrush. You can substitute with the colors you really want.

HTH,
Tom T.

"Alex K." wrote:
I have DataGrid linked to a data table. I want to be able to show particular
column in different color, depending on some other column values in the same
line.
Any ideas how to do this?
Thank you

Nov 16 '05 #6

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

Similar topics

0
by: Kumar | last post by:
try this Dim mycheck As CheckBox = CType(dgWelcomePacks.Items (i).Cells(7).Controls(1), CheckBox) regards, Kumar. >-----Original Message-----
5
by: Ariel Gimenez | last post by:
Morning! After several hours breaking my mind, finally my code works, but i think is trash-code, can someone tellme how is the correct way to access the value of my cells within a datagrid?... in...
2
by: Craig Buchanan | last post by:
Is there a way to add a row to a datagrid during the ItemDataBound event? I would like to add a 'header' row before the start of a group of rows. Thanks, Craig Buchanan
4
by: EMW | last post by:
For my ASP.NET program I want to use the datagrid as a sort of planning tool. Based on the information in a XML file, a cell of the datagrid must show an image... Well, this is what I would...
1
by: martin | last post by:
Hi, I have a datagrid that contains 3 colums. This is rendered to the page fine, except that I would like to be able to control the width of each table cell of the datagrid I have the following...
3
by: tshad | last post by:
How do I get blank cells to show in my dataGrid? I am databinding to my datagrid, but any cells that are blank, don't show. Normally, you would put an &nbsp in the cell to make IE display the...
1
by: David Tilman | last post by:
I have an ASP .NET web application that changes datagrid cells in the ItemDataBound event, like changing the Columnspan of a cell to 2 and deleting the adjacent cell, so that I have two cells...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
5
by: ruca | last post by:
Hi, Can anyone give me examples of how can I hightlight cells of my datagrid? I know that I must use ItemBound event and probably JavaScript. The thing is that I have a anual calendar,...
0
by: rn5a | last post by:
This is the code of a DataGrid: <asp:DataGrid ID="dgCart" OnEditCommand="EditCart" OnCancelCommand="CancelUpdate" OnDeleteCommand="DeleteFromCart" OnItemCommand="ButtonClicked"...
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: 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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.