This is a migrated thread and some comments may be shown as answers.

CellLoaded and RowLoaded Event

0 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rever
Top achievements
Rank 1
Rever asked on 21 Feb 2012, 09:10 AM
HI,I would like change the cell background,so I used CellLoaded and RowLoaded.
but have a issue,the CellLoaded can't change the cell background(RowLoaded can work ).
I don't what happen.
RowLoaded Event
for (int i = 0; i < e.Row.Cells.Count; i++)
{
    GridViewCell mark = e.Row.Cells[i] as GridViewCell;
 
    string markValue = mark.Value as string;
    if (markValue != null)
    {
        List<string> TEST = new List<string>();
        string[] t = markValue.Split(',');
        foreach (string item1 in t)
        {
            if (item1 == "NE")
            {
                e.Row.Cells[i].Background = new SolidColorBrush(Colors.LightGray);
            }
        }

    }
}
CellLoaded Event
void RgvVerify_CellLoaded(object sender, CellEventArgs e)
       {
               GridViewCell mark = e.Cell as GridViewCell;
               if (mark != null)
               {
                   string markValue = mark.Value as string;
                   if (markValue != null)
                   {
                       List<string> TEST = new List<string>();
                       string[] t = markValue.Split(',');
                       foreach (string item1 in t)
                       {
                           if (item1 == "NE")
                           {
                               mark.Background = new SolidColorBrush(Colors.Green);
                           }
                       }
                   }
               }
       }
 

btw:I also try used StyleSelector,but it  can't 

thanks.
rever.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Rever
Top achievements
Rank 1
Share this question
or