RadTitleBar Close Event

4 posts, 0 answers
  1. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jul 2008

    Posted 30 Oct 2008 Link to this post

    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
  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 30 Oct 2008 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jul 2008

    Posted 30 Oct 2008 Link to this post

    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.

     

  5. Angel
    Admin
    Angel avatar
    121 posts

    Posted 04 Nov 2008 Link to this post

    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.
Back to Top