Telerik, How do I correctly add a RadButton element to a RadForm TitleBar?

I am trying to add a button to the title, I would like to give it the same aspect as the other buttons, but I cannot do that, see

enter image description here

Notice that my new button is blue in color than the others, and that the size is highlighted with a yellowed border.

This is the code I'm using:

Imports Telerik.WinControls.UI

Public Class RadForm_TestForm : Inherits RadForm

Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Set the RadForm design.
    With Me

        .ThemeName = "VisualStudio2012Dark" ' The visual theme.
        .FormElement.Border.ForeColor = Color.Gold   ' Set the borders color.
        .FormElement.Border.Width = 1I ' Set the borders width.
        .FormElement.TitleBar.BorderPrimitive.ForeColor = Color.Red
        .FormElement.TitleBar.ForeColor = Color.LightGray ' Set the TitleBar text color.
        .FormElement.TitleBar.MinimizeButton.Enabled = False

    End With

    ' Create a RadButtonElement.
    Dim SystrayButton As New RadButtonElement()
    With SystrayButton ' Set the RadForm design.

        .Text = "."
        .ShowBorder = False
        .AutoSize = False

        .Size = Me.FormElement.TitleBar.MinimizeButton.Size
        '  .ButtonFillElement.BackColor = Me.FormElement.TitleBar.MinimizeButton.BackColor

    End With

    ' Add the Button in the TitleBar.
    Me.FormElement.TitleBar.Children(2).Children(0).Children.Insert(0, SystrayButton)

End Sub

End Class

      

Note that in the above code, this line is off:

.ButtonFillElement.BackColor = Me.FormElement.TitleBar.MinimizeButton.BackColor

      

Because if I change the color this way, if I hover the cursor over the button, it doesn't change color when it is focused.

Update:

Perhaps a solution could apply the same theme of mine RadForm

to RadButtonElement

?

I read this: http://www.telerik.com/forums/apply-theme-to-radbuttonelement

... but I really don't understand how to do this, I don't have a "DefaultStyleBuilder" and I can't find any information on the TV about what that means.

+3


source to share


2 answers


Solution suggested by the Telerik forums administrator:

The FormElement.TitleBar.SystemButtons collection contains RadImageButtonElements. To add a new system button to the title bar, you must create a RadImageButtonElement. Also, to get the same design as the Minimize button, you must set the RadImageButtonElement.ThemeRole property to TitleBarMinimizeButton. Subsequently, change the DisplayStyle property to Text. Here's a sample snippet of code:

Sub New()
    InitializeComponent()

    With Me
        .ThemeName = "VisualStudio2012Dark" ' The visual theme.
        .FormElement.Border.ForeColor = Color.Gold ' Set the borders color.
        .FormElement.Border.Width = 1I ' Set the borders width.
        .FormElement.TitleBar.BorderPrimitive.ForeColor = Color.Red
        .FormElement.TitleBar.ForeColor = Color.LightGray ' Set the TitleBar text color.
        .FormElement.TitleBar.MinimizeButton.Enabled = False
    End With

    ' Create a RadButtonElement.
    Dim systrayButton As New RadImageButtonElement()
    With systrayButton ' Set the RadForm design.
        .ThemeRole = "TitleBarMinimizeButton"
        .Text = "."
        .DisplayStyle = Telerik.WinControls.DisplayStyle.Text
        .ShowBorder = False
        .AutoSize = False
        .Size = Me.FormElement.TitleBar.MinimizeButton.Size
    End With
    AddHandler systrayButton.Click, AddressOf systrayButton_Click
    ' Add the Button in the TitleBar.
    Me.FormElement.TitleBar.SystemButtons.Children.Insert(0, systrayButton)
End Sub

Private Sub systrayButton_Click(sender As Object, e As EventArgs)
    Me.Size = New Size(600, 600)
End Sub

      



enter image description here

Source: http://www.telerik.com/forums/how-to-properly-add-a-radbuttonelement-in-a-radform-titlebar

0


source


+1 I see a riddle.

If you want to have hover, pressed and normal button states in the title, you need to create three images and apply them to mouse events, that is, apply the hover image to MouseEnter, normal image to MouseLeave, and click to MouseDown.

I can see how the button slightly overlaps the yellow line, so you may need to solve this with images.

Setting the RadButton BackColors as you say will prevent the default behavior, click and normal state.



It looks like you are doing it right - one small change is using TitleBar.SystemButtons

instead of passing the inheritedTitleBar.Children(2).Children(0).Children.

Here's how you can do it:

RadButtonElement btn = new RadButtonElement();
btn.ShowBorder = false;
btn.Image = Resources.NormalState;
this.FormElement.TitleBar.SystemButtons.Children.Insert(0,btn);

      

ps I don't think you can achieve what you need with "StyleBuilders" and by the way this suggestion was suggested by Telerik: http://feedback.telerik.com/Project/154/Feedback/Details/109772- add-helpbutton-at-the-titlebar-of-radform

+2


source







All Articles