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 minimize, maximize/restore and close buttons. You can access the RadFormTitleBarElement the following way:
Copy[C#] Accessing RadForm elements
void Form1_Shown(object sender, EventArgs e)
{
this.FormElement.TitleBar.MaximizeButton.Enabled = false;
this.FormElement.TitleBar.MinimizeButton.Enabled = false;
}
Copy[VB.NET] Accessing RadForm elements
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
End Sub
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:
Copy[C#] 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);
}
Copy[VB.NET] Adding new button to the title bar
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:
Copy[C#] Accessing the FormBorderPrimitive
this.FormElement.Border.ForeColor = System.Drawing.Color.Green;
Copy[VB.NET] Accessing the FormBorderPrimitive
Me.FormElement.Border.ForeColor = System.Drawing.Color.Green
Note |
|---|
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:
Copy[C#] Accessing the FormImageBorderPrimitive
this.FormElement.ImageBorder.BackColor = Color.Lime;
Copy[VB.NET] Accessing the FormImageBorderPrimitive
Me.FormElement.ImageBorder.BackColor = Color.Lime