Grid Formatting

Posted on 2012-08-10
Medium Priority
Last Modified: 2012-08-12
I am working on windows form.
I have code to change backcolor for cell in the row , but I need to change backcolor for all cells in same row

        private void dgAC_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)

                if (e.Value is System.DBNull || e.Value is System.DateTime || e.Value is System.Int32) return;
                if (dgACT.Columns[e.ColumnIndex].DataPropertyName == "Status")
                                if (Convert.ToString(e.Value) == "Over")
                                    e.CellStyle.BackColor = System.Drawing.Color.Red;
                        e.CellStyle.ForeColor = System.Drawing.Color.White;

                e.FormattingApplied = true;
Question by:samprg
  • 2
LVL 12

Accepted Solution

Kaushal Arora earned 1000 total points
ID: 38283123
Have a look at this link:


Hope it helps you.
LVL 60

Assisted Solution

by:Julian Hansen
Julian Hansen earned 1000 total points
ID: 38283232

Author Comment

ID: 38285695
I have tried use both your codes but I did not succes because I am using C# and codes VB
and I did not find the events in C#

KaushalArora, I need to do like your code
I need a little help, Thanks

Author Closing Comment

ID: 38285773
Guys, I got it, Thanks for help
 int rx = e.RowIndex;
 dgACT.Rows[rx].DefaultCellStyle.BackColor = System.Drawing.Color.Red;

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

839 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