Group Header

8 posts, 0 answers
  1. Rene
    Rene avatar
    8 posts
    Member since:
    Mar 2013

    Posted 16 Mar 2013 Link to this post

    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
  2. Rene
    Rene avatar
    8 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    can anyone help me pls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Rene
    Rene avatar
    8 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    I can not say how I change a single color Grouprow?
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 Mar 2013 Link to this post

    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.
  6. Rene
    Rene avatar
    8 posts
    Member since:
    Mar 2013

    Posted 21 Mar 2013 Link to this post

    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?
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Mar 2013 Link to this post

    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.
  8. Claudio
    Claudio avatar
    1 posts
    Member since:
    Jul 2015

    Posted 14 May in reply to Stefan Link to this post

    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

  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 16 May Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready