?
Solved

Grid Formatting

Posted on 2012-08-10
4
Medium Priority
?
557 Views
Last Modified: 2012-08-12
Hi,
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;
}
0
Comment
Question by:samprg
  • 2
4 Comments
 
LVL 12

Accepted Solution

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

http://msdn.microsoft.com/en-us/library/ms996485.aspx

Hope it helps you.
0
 
LVL 60

Assisted Solution

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

Author Comment

by:samprg
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
0
 

Author Closing Comment

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

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