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

cell formating

1 Answer 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Hans asked on 05 Aug 2010, 05:02 PM
Hi !

I tried to follow the example for cell formating from your tutorial but this functions is not working

Private Sub radGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs)
 If e.CellElement.ColumnInfo.HeaderText = "column2" Then
  If e.CellElement.Text = "H" Then
   e.CellElement.RowInfo.Cells("column1").CellElement.ForeColor = Color.Red
  Else
   e.CellElement.RowInfo.Cells("column1").CellElement.ForeColor = Color.Black
  End If
 End If
End Sub


e.CellElement.RowInfo.Cells(0) doesn't have any CellElement property !


How I can access another cell from another column in order to change the colour?

Regards,
Hans


1 Answer, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 09 Aug 2010, 01:25 PM
Hi Hans,

We are in the process of upgrading our documentation to include information on updated properties. In your case, you have stumbled upon a change we introduced in Q2, and which you can read about in this blog post. I suppose that your code snippet should look like the following code snippet:

Private Sub radGridView2_ViewCellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs)
    Dim isColumn1 As Boolean = e.CellElement.ColumnInfo.Name = "column1"
 
    If isColumn1 Then
        Dim row As GridViewRowInfo = e.CellElement.RowInfo
        Dim cellValue As String = String.Empty
        Dim value As Object = row.Cells("column2").Value
 
        If value IsNot Nothing AndAlso (Not Convert.IsDBNull(value)) Then
            cellValue = Convert.ToString(cellValue)
        End If
 
        If cellValue = "H" Then
            e.CellElement.ForeColor = Color.Red
        Else
            e.CellElement.ForeColor = Color.Black
        End If
    Else
        e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local)
    End If
End Sub

The documentation will be updated shortly.

Best wishes,
Svett
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Hans
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or