Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Change the style of cell within datagrid RSS

17 replies

Last post Sep 23, 2011 11:30 AM by Andy Chen

(0)
  • John_II

    John_II

    Member

    6 Points

    4 Posts

    Re: Re: Change the style of cell within datagrid

    Mar 10, 2009 08:04 PM | LINK

    I am having the same problem with column.GetCellContent(e.Row). It always returns null. So why do people keep saying that it works? It doesn't work. And I spent most my day searching online for the solution to this problem. Very annoying...

    I am trying to replace values in the row as it is loaded. For example, if a value equals "-100", I want it to display as blank. 

     

    DataGrid Beta2

  • Terian

    Terian

    Member

    4 Points

    2 Posts

    Re: Re: Change the style of cell within datagrid

    Mar 11, 2009 09:52 AM | LINK

     John,

    I gave up in the end, I went this route instead...

    http://wpf.codeplex.com/Thread/View.aspx?ThreadId=49605

    Hope that helps you too.

  • puneetpriyadarshi

    puneetpriyad...

    Member

    28 Points

    17 Posts

    Re: Re: Change the style of cell within datagrid

    Jun 07, 2009 02:02 PM | LINK

     Try This it might help...

     

    Thanks,

    puneet

  • Bhagirath Patadia

    Bhagirath Pa...

    Participant

    1244 Points

    214 Posts

    Re: Change the style of cell within datagrid

    Jun 10, 2009 10:16 AM | LINK

    Hi, Amanda

     

    Thanks for snippet, it worked for me... I was also trying the same thing and it worked


    Bhagirath Patadia

    If this matches your answer then MARK IT AS ANSWER
  • Prateek1

    Prateek1

    Member

    175 Points

    48 Posts

    Re: Change the style of cell within datagrid

    Jul 15, 2009 01:25 PM | LINK

    Hi Amanda , Thanx but i got that ereror when my task is complete succefully so what is the problem "Object reference not set to an instance of an object". Thanx in Advance
    Regard

    Prateek Bhatnagar (BCA & MCA)

    Prateek'Tips


    www.msdotnetheaven.com

  • Rahul Burgute

    Rahul Burgute

    Member

    8 Points

    15 Posts

    Re: Re: Change the style of cell within datagrid

    Sep 30, 2009 07:11 AM | LINK

    Hi can i check the cell value in this event...??

    private void Grid1stQuad_LoadingRow(object sender, DataGridRowEventArgs e)

    {

     

    FrameworkElement fe = col.GetCellContent(e.Row);

    FrameworkElement result = GetParent(fe, typeof(DataGridCell));

    }

  • jigs_jignesh

    jigs_jignesh

    Member

    182 Points

    42 Posts

    Re: Re: Change the style of cell within datagrid

    Sep 30, 2009 07:55 AM | LINK

    you can try this

      Private Sub Alert_RowLoaded(ByVal sender As Object, ByVal e As DataGridRowEventArgs)
            Dim objCOl As ObservableCollection(Of BindableObject)
            objCOl = CType(CType(sender, DataGrid).ItemsSource, ObservableCollection(Of BindableObject))
            Dim dr As DataRow

            dr = objCOl(e.Row.GetIndex).DataRow

            'dr(0) is your cell value

            If dr(0).ToString.Contains("Pending") Then
                e.Row.Background = New SolidColorBrush(Colors.Red)
            End If
        End Sub

    Thanks,
    Jignesh
    Please mark the replies as answers if they answered your question.
  • Andy Chen

    Andy Chen

    Member

    2 Points

    1 Post

    Re: Change the style of cell within datagrid

    Sep 23, 2011 11:30 AM | LINK

    Hi All, FrameworkElement result = GetParent(fe, typeof(DataGridCell)); Who can tell me the GetParent(,) method of the above code which come from where in silverlight. Thanks, -Andy Chen