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

How do I add a listener to only the header of a form?

3 Answers 61 Views
TabbedForm
This is a migrated thread and some comments may be shown as answers.
Serg
Top achievements
Rank 1
Veteran
Serg asked on 25 Dec 2020, 04:47 AM

How to add a click event to the form header? How to do it so that the event fires only when you click on the header, excluding buttons and tabs.

For clarity, I have highlighted the area in the picture below, only it should react to the event.

3 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 25 Dec 2020, 08:11 AM

Hello, Serg,

In this case, I can suggest to handle the MouseDown event on the TabbedFormControlTabsElement:

this.TabbedFormControl.TabbedFormControlTabsElement.MouseDown += this.TabbedFormControlTabsElement_Click;
private void TabbedFormControlTabsElement_Click(object sender, EventArgs e)
{
    Console.WriteLine("TabbedFormControlTabsElement is clicked");
}

I hope this helps. Should you have other questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Serg
Top achievements
Rank 1
Veteran
answered on 26 Dec 2020, 01:38 AM
The reason I am trying to do is to disable the ControlBox. When I disabled ControlBox and system buttons (Minimaze, Maximaze, Close), the function of switching between WIndowState modes (Normal <=> Maximaze) stopped working when I double-clicked on the window header.
Now I want to restore this function with a listener. Did I choose the right path for the solution? Or can you suggest another solution?
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 28 Dec 2020, 10:37 AM

Hello, Serg,

According to the provided information in your last post, it seems that you have removed the Minimize, Maximize, and Close buttons from the caption in TabbedFormControl. Now, you would like to maximize the form when you double click on the form's title bar and revert back to normal state when the form is maximized. 

In order to achieve this, I can suggest handling TabbedFormControlTabsElement.DoubleClick event and achieve this. Below is a sample code snippet which result is illustrated in the attached gif file. When I double click on the form's title bar the form gets maximized, then when I double click the title bar again the form gets back to its normal state.

this.TabbedFormControl.TabbedFormControlTabsElement.DoubleClick += this.TabbedFormControlTabsElement_DoubleClick;
private void TabbedFormControlTabsElement_DoubleClick(object sender, EventArgs e)
{
    if (this.WindowState == FormWindowState.Normal)
    {
        this.WindowState = FormWindowState.Maximized;
    }
    else if (this.WindowState == FormWindowState.Maximized)
    {
        this.WindowState = FormWindowState.Normal;
    }
}

I hope this helps. Should you have other questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TabbedForm
Asked by
Serg
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Serg
Top achievements
Rank 1
Veteran
Share this question
or