Changing the backcolor of a entire row in DataGrid

Posted on 2004-10-16
Last Modified: 2010-04-15
I have a Datagrid and create TableStyle and ColumnStyle for it. I want to change the backcolor of a entire row if the specific column of that row have one of my values.

ColA    ColB    ColC    ColD
1        A         a        Y
2        B         b        R
3        C         c         R
4        D         d        W
5        E         e         Y
6        F         f          W

I want to change the color of **entire** rows 1,5 to yellow.

I searched the EE and Net for it. But what I find is changing the color of a column not entire row.

Thanks for your help,
Question by:Farzad Akbarnejad
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 12331616
You can change row colors using following code. Put this code after filling your grid. (It should be in your page_load) Remember that first rows index is zero.

dataGrid.Items[0].Style["BACKGROUND-COLOR"] = "yellow";
dataGrid.Items[4].Style["BACKGROUND-COLOR"] = "yellow";

LVL 14

Author Comment

by:Farzad Akbarnejad
ID: 12332180
my Data Grid hasn't Items member. Maybe it was in Web Controls. I am using System.Windows.Form. I am developing Windows Application.

LVL 70

Expert Comment

by:Éric Moreau
ID: 12332535
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

LVL 14

Author Comment

by:Farzad Akbarnejad
ID: 12333021
I visited your link before that I found it in EE solutions. It is about changing a cell not entire row.
I want to change the color of entire row.

I found the following link that its downloadable sample code is very valuable.
I solved my problem by helping of it.

I want to close this question with Points Refund. Any Suggestion?

LVL 70

Expert Comment

by:Éric Moreau
ID: 12333235
You have to ask a 0-point question into the community support topic

Accepted Solution

RomMod earned 0 total points
ID: 12374079
The question has been PAQ'd and the 500 points have been refunded.
Community Support Moderator

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question