Edit this page

Accessing RadForm Elements

The RadForm is build of a RadFormTitleBarElement, FormBorderPrimitive and a FormImageBorderPrimitive. The following topic demonstrates how to access and modify these elements.

Accessing the RadTitleBarElement

The RadFormTitleBarElement is positioned on the top of the form and its default behavior is to display an icon, text, and the help, minimize, maximize/restore and close buttons. You can access the RadFormTitleBarElement the following way:

Accessing RadForm elements

void Form1_Shown(object sender, EventArgs e)
    this.FormElement.TitleBar.MaximizeButton.Enabled = false;
    this.FormElement.TitleBar.MinimizeButton.Enabled = false;
    this.FormElement.TitleBar.HelpButton.Visibility = Telerik.WinControls.ElementVisibility.Visible;

Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    Me.FormElement.TitleBar.MaximizeButton.Enabled = False
    Me.FormElement.TitleBar.MinimizeButton.Enabled = False
    Me.FormElement.TitleBar.HelpButton.Visibility = Telerik.WinControls.ElementVisibility.Visible
End Sub

Figure 1: TitleBar

forms-and-dialogs-accessing-radform-elements 001


By default, the HelpButton is not shown. Set the HelpButton property to true to display a Help button in the form's caption bar.The value of the HelpButton property is ignored if the Maximize or Minimize buttons are shown.
An alternative solution is to set its Visibility property to ElementVisibility.Visible in order to be displayed. The HelpButtonClicked event is fired when Help button in the title bar is clicked. It can be canceled. However, if it is not canceled, the HelpRequested event will be fired when the Help cursor is clicked on any Control.

Adding a new button to the title bar

You can easily extend the RadFormTitleBarElement 's functionality by adding new elements to its hierarchy. The following code snippet demonstrated how to add a RadButtonElement before the minimize button in the RadFormTitleBarElement:

Adding new button to the title bar

void Form1_Load(object sender, EventArgs e)
    RadButtonElement buttonElement = new RadButtonElement();
    buttonElement.Text = "TitleBar Button";
    this.FormElement.TitleBar.Children[2].Children[0].Children.Insert(0, buttonElement);

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim buttonElement As New RadButtonElement()
    buttonElement.Text = "TitleBar Button"
    Me.FormElement.TitleBar.Children(2).Children(0).Children.Insert(0, buttonElement)
End Sub

Accessing the Form Borders

The border of a RadForm control is composed of two border primitives which, together, define the visual appearance of the whole border: FormBorderPrimitive and FormImageBorderPrimitive.

Accessing the FormBorderPrimitive

The FormBorderPrimitive represents the outer thin border that surrounds a RadForm control. The following code snippet demonstrates how to modify the color of this primitive:

Accessing the FormBorderPrimitive

this.FormElement.Border.ForeColor = System.Drawing.Color.Green;

Me.FormElement.Border.ForeColor = System.Drawing.Color.Green


The visual appearance of the border and also for the whole RadForm control can be designed in the Visual Style Builder.

Accessing the FormImageBorderPrimitive

The FormImageBorderPrimitive represents the inner thick border that starts from the bottom-left corner of the title bar, surrounds the RadForm control and ends at the bottom-right corner of the title bar. The FormImageBorderPrimitive provides you with the possibility to define borders for your form which are built of images and thus achieve better look-and-feel for your form. Without images set, the FormImageBorderPrimitive paints as a one-color-border with the color set to the BackColor property of the primitive.

The following code snippet demonstrates how to set the BackColor of the FormImageBorderPrimitive which is painted when no images are defined:

Accessing the FormImageBorderPrimitive

this.FormElement.ImageBorder.BackColor = Color.Lime;

Me.FormElement.ImageBorder.BackColor = Color.Lime


More information on how to use the FormImageBorderPrimitive can be found in the separate topic: Using the FormImageBorderPrimitive.