Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am wanting to change the backcolor of a specific row/cell in a DataGridView control using the following code:

 

private void CustomGridCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
       {
           if (dgSearchResults.Columns[e.ColumnIndex].Name.Equals("column1"))
           {
               // Ensure that the value is a string.
               String stringValue = e.Value as string;
               if (stringValue == null) return;

               switch (stringValue)
               {
                   case "G":
                       e.CellStyle.BackColor = Color.Gold;
                       break;
                   case "S":
                       e.CellStyle.BackColor = Color.Silver;
                       break;
                   case "N":
                       break;
               }
           }
       }

 

This delegate gets called but the backcolor doesn't change. Am I missing something?

 

tia,

flynn

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...