Grid Formatting

Posted on 2012-08-10
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
    LVL 12

    Accepted Solution

    Have a look at this link:

    Hope it helps you.
    LVL 50

    Assisted Solution

    by:Julian Hansen

    Author Comment

    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

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    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.…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now