Setting user defined image for help button in title bar

1 Answer 23 Views
Form TitleBar
Toby
Top achievements
Rank 1
Toby asked on 02 Nov 2021, 12:23 PM

Hi, How do I go about setting my own image for the help button shown in the title bar at run-time of a RadForm ? I can get the '?' button up but I want to change this form something else.

Thanks Toby

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko
Telerik team
answered on 03 Nov 2021, 01:12 PM

Hello Toby,

You can use the following code snippet to change the default image of the HelpButton.

public RadForm1()
{
    InitializeComponent();
    this.FormElement.TitleBar.HelpButton.Visibility = ElementVisibility.Visible;
    RadImageShape imageShape = new RadImageShape();
    imageShape.Image = Image.FromFile(@"C:\..\..\MyImage.PNG");
    this.FormElement.TitleBar.HelpButton.Image = imageShape.Image;
    this.FormElement.TitleBar.HelpButton.DisplayStyle = DisplayStyle.Image;
}

Keep in mind that you need to set the DisplayStyle property of the HelpButton to Image. Otherwise, the Image property won't be respected.

I hope you find this reply helpful.

Regards,
Dinko
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Toby
Top achievements
Rank 1
commented on 03 Nov 2021, 04:46 PM | edited

I've just tried your suggested solution and it works, but only when the ThemeName of the form is set to something other than ControlDefault. If it is set to ControlDefault i see a '?' rather than my image.

I can reproduce this when a new project and an empty form.

Is it possible to set the image when the ThemeName is set to ControlDefault ?

Dinko
Telerik team
commented on 04 Nov 2021, 09:16 AM

In the ControlDefault theme, the HelpButton is using SVG image for its question mark. The SvgImage of the ImagePrimitive has a higher priority than the Image property. To respect the image property you can reset the SvgImage property value by setting it to null.

public RadForm1()
{
    InitializeComponent();
    this.FormElement.TitleBar.HelpButton.Visibility = ElementVisibility.Visible;
    RadImageShape imageShape = new RadImageShape();
    imageShape.Image = Image.FromFile(@"C:\..\..\MyImage.PNG");
    this.FormElement.TitleBar.HelpButton.ImagePrimitive.SvgImage = null;
    this.FormElement.TitleBar.HelpButton.Image = imageShape.Image;
    this.FormElement.TitleBar.HelpButton.DisplayStyle = DisplayStyle.Image;
}

Toby
Top achievements
Rank 1
commented on 04 Nov 2021, 05:01 PM

Perfect, setting SvgImage to null solved the problem for me
Tags
Form TitleBar
Asked by
Toby
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or