could you tell me how do I change the header (see attachment) with a button click event.
I would like to change the font color or the background color
I did it myself header hinbekommen the micelles to change color with a button, but unfortunately I can not find the code for the group
with this code can i change the cell color
RadGridView1.Rows(i).Cells(b).Style.BackColor = Color.Yellow
RadGridView1.Rows(i).Cells(b).Style.CustomizeFill = True
this works fine
Please help me
I use Visual Basic not C
regards
7 Answers, 1 is accepted
Thank you for writing.
If I understand correctly, you want to style the cells in the group row. If so, the correct way to do that is the ViewCellFormatting event of the control. Please refer to the "Example 2: Change TextAlignment and BackColor of group rows", in this help article: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.
To do this on a button click, you have to use some flag in the formatting event and call the Refresh method of the desired template to force firing the formatting event.
I hope this helps.
All the best,
Stefan
the Telerik team
Private
Sub
RadGridView1_ViewCellFormatting2(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Handles
RadGridView1.ViewCellFormatting
If
TypeOf
e.CellElement.RowInfo
Is
GridViewGroupRowInfo
Then
e.CellElement.DrawFill =
True
e.CellElement.BackColor = Color.Aquamarine
e.CellElement.TextAlignment = ContentAlignment.MiddleRight
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
Else
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
End
If
End
Sub
change all Group Rows Backcolor.
I like change the first Group Row Red the next Group Row Blue
How can i make this?
Can you please try the code below:
Private
Sub
RadGridView1_ViewCellFormatting(sender
As
Object
, e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Handles
RadGridView1.ViewCellFormatting
Dim
groupRow
As
GridViewGroupRowInfo = TryCast(e.Row, GridViewGroupRowInfo)
If
groupRow IsNot
Nothing
Then
If
groupRow.Index = 0
Then
e.CellElement.BackColor = Color.Red
Else
e.CellElement.BackColor = Color.Blue
End
If
e.CellElement.DrawFill =
True
e.CellElement.TextAlignment = ContentAlignment.MiddleRight
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
Else
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local)
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
End
If
End
Sub
I hope this helps.
Greetings,
Stefan
the Telerik team
Good morning this works for me that i wanto to color background group descriptor by level and not by index
Dim groupRow As GridViewGroupRowInfo = TryCast(e.Row, GridViewGroupRowInfo)
If groupRow IsNot Nothing Then
Select Case groupRow.GroupLevel
Case 0
e.CellElement.BackColor = Color.DeepSkyBlue
Case 1
e.CellElement.BackColor = Color.SkyBlue
Case 2
e.CellElement.BackColor = Color.PaleTurquoise
Case 3
e.CellElement.BackColor = Color.LightCyan
Case 4
e.CellElement.BackColor = Color.Azure
Case Else
e.CellElement.BackColor = Color.Azure
End Select
Thank you for writing.
Indeed, this is a valid solution. Due to the UI virtualization please do not forget to reset the styles defined in formatting events: UI Virtualization.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik