Thursday, April 14, 2016

Working Events of Telerik Grid View Windows Controls

Here is some events where you can do some operations while working with telerik gridview.

(1) Cell double click :- You can do some functionality while clicking over cell of the grid item, it could be anything like opening a another form in edit mode or anything.
Private Sub grid_CellDoubleClick(sender As Object, e As EventArgs) Handles grid.CellDoubleClick
'Your code goes here        
End Sub

(2) Row Formatting :- When you want to do some operations on your grid items this event comes to you. for me, on some operation i need to show items color to red, i checked its column value and if it meets requirement make it red else reset value of the.
Private Sub rgdAvailResult_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles rgdAvailResult.RowFormatting
    If e.RowElement.RowInfo.Cells("column1").Value Then
       e.RowElement.ForeColor = System.Drawing.Color.Red
    Else
       e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    End If
End Sub

(3) View Row Formatting :- for rows related general event to work with different items of the grid. For me, to show filter bar in different color format, i use this event. So, if the item is filterrow then change is color else reset value to original.
Private Sub grid_ViewRowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs)
        If TypeOf e.RowElement Is GridFilterRowElement Then
            e.RowElement.BackColor = Color.NavajoWhite
        Else
            e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        End If
    End Sub

So, these are some events which are i found for my resolution. 

No comments:

Post a Comment