This is a migrated thread and some comments may be shown as answers.

RadTitleBar Close Event

3 Answers 281 Views
TitleBar
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 30 Oct 2008, 03:57 PM
How can I access the title-bar (of a RadForm) click-close event?

If I can't do that, how do I add a button element to the title bar?

Ryan

3 Answers, 1 is accepted

Sort by
0
Angel
Telerik team
answered on 30 Oct 2008, 07:45 PM
Hello Ryan,

Thank you for writing. Here are the answers to your questions:

1. Close event
There are two options:
  • Use the form's FormClosing or FormClosed events. The FormClosing event allows you to cancel the closing and the form will remain open. These events are fired for all ways used for closing the form (from the context menu, double click on the image, Alt+F4 keyboard combination, etc.).
  • Use the close button click event - this will be called ONLY when the close button is clicked. Just handle the FormElement.TitleBar.CloseButton.Click event.
2. Add a button element to the title bar
You have to add elements in the non-client area which will be possible in the upcoming release. The API is extended and the elements will have SetNCElement method. See below how to insert a button before the minimize button:

RadImageButtonElement button = new RadImageButtonElement();  
button.SetNCElement(true);  
button.Image = ...;  
RadElement buttonStack = this.FormElement.TitleBar.Children[2].Children[0];  
buttonStack.Children.Insert(0, button); 

In order to add button after the close button use Children.Add() instead of Children.Insert().

 
Greetings,
Angel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ryan
Top achievements
Rank 1
answered on 30 Oct 2008, 07:56 PM

I'm trying to handle the FormElement.TitleBar.CloseButton.Click event.

Can you post the VB.Net code for accessing this event?

Public
Sub CloseClicked() Handles ??????

 

 

End Sub

I haven't been able to access that event.

 

0
Angel
Telerik team
answered on 04 Nov 2008, 08:47 AM
Hello Ryan,

The VB code for handling the click event of the close button is given below:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  
    AddHandler Me.FormElement.TitleBar.CloseButton.Click, AddressOf Me.TitleCloseButton_Click  
End Sub  
 
Private Sub TitleCloseButton_Click(ByVal sender As Object, ByVal e As EventArgs)  
    MessageBox.Show("Message")  
End Sub 

It seems that the click event was not fired for non-client elements such as the buttons in the TitleBar.
This issue is addressed now and the update will be available in the upcoming release later this week.

If you do not wish to switch to the latest version, you will have to use the form events Closing and Close.
 

Greetings,
Angel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TitleBar
Asked by
Ryan
Top achievements
Rank 1
Answers by
Angel
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or