Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datagridview cell formatting
Message
From
11/06/2010 19:27:53
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
11/06/2010 18:06:55
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01468613
Message ID:
01468631
Views:
36
Bill,

Now that I understand your question, I woudl think you can reference the other cell and set those same values with these right in the code you have.
this.dataGridViewTrackingSearch.CurrentRow.Cells["ColumnSono"].Style.BackColor = Color.Blue;
this.dataGridViewTrackingSearch.CurrentRow.Cells["ColumnSono"].Style.SelectionBackColor = Color.Aqua;
Tim

>The code below sets the backcolor of the ColumnHasComments column to Red if the source data table record has "Y" in the hascomment field.
>That works fine.
>How would I set the backcolor of another column (ColumnSono) to Red for the same condition (hascomment = "Y")
>
>
>
> private void dataGridViewTrackingSearch_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
>     {
>       if (dataGridViewTrackingSearch.Columns[e.ColumnIndex].Name.Equals("ColumnHasComment"))
>       {
>         if (e.Value != null)
>         {
>          
>           if (e.Value.ToString() == "Y")
>           {
>             e.CellStyle.BackColor = Color.Red;
>             e.CellStyle.SelectionBackColor = Color.DarkRed;
>           }
>         }
>       } 
>     } // end CellFormatting
>
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform