luni, 25 august 2014

How to change colums color to RadGridView (VB.NET)

Telerik > RadGridView > Cell Formatting

CellFormatting event is used to add formatting to grid cells

Because of UI virtualization in RadGridView, cell elements are created only for currently visible cells.
To prevent applying the formatting to other columns' cell elements all customization should be reset for the rest of the cell elements. 
           
Example: 
Change Forecolor in CellFormating Events
 

Imports Telerik.WinControls.UI 
Imports Telerik.WinControls

Private Sub grd_CellFormatting(sender As System.Object, e AsTelerik.WinControls.UI.CellFormattingEventArgsHandles grd.CellFormatting
  
 If e.CellElement.ColumnInfo.Name = "total" Then 
  e.CellElement.ForeColor = Color.Blue
  Else
   e.CellElement.ResetValue(LightVisualElement.ForeColorProperty,ValueResetFlags.Local)
  End If

 End Sub

Niciun comentariu:

Trimiteți un comentariu