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

Group Header

7 Answers 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 16 Mar 2013, 06:26 PM
Hello,

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

Sort by
0
Rene
Top achievements
Rank 1
answered on 18 Mar 2013, 07:51 AM
can anyone help me pls.
0
Rene
Top achievements
Rank 1
answered on 18 Mar 2013, 06:51 PM
I can not say how I change a single color Grouprow?
0
Stefan
Telerik team
answered on 20 Mar 2013, 01:21 PM
Hi Rene,

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
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Rene
Top achievements
Rank 1
answered on 21 Mar 2013, 07:47 AM
This Code
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?
0
Stefan
Telerik team
answered on 25 Mar 2013, 05:28 PM
Hello Rene,

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
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Claudio
Top achievements
Rank 1
answered on 14 May 2016, 08:34 AM

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

0
Hristo
Telerik team
answered on 16 May 2016, 03:42 PM
Hi Claudio,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Rene
Top achievements
Rank 1
Answers by
Rene
Top achievements
Rank 1
Stefan
Telerik team
Claudio
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or