CellLoaded and RowLoaded Event

1 posts, 0 answers
  1. Rever
    Rever avatar
    2 posts
    Member since:
    Oct 2011

    Posted 21 Feb 2012 Link to this post

    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.
Back to Top