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

Tab Close vs. Tab Dragged Out

2 Answers 11 Views
TabbedForm
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
Veteran
n/a asked on 14 Jan 2021, 04:06 AM

I want to distinguish between: 

A) Tab close.

B) Tab being dragged out into a new parent window  

 

Both of the above call: TabRemoving, TabRemoved

What is the proper event or technique to distinguish between A and B?

2 Answers, 1 is accepted

Sort by
0
Accepted
Nadya
Telerik team
answered on 14 Jan 2021, 04:19 PM

Hello, Craig,

The tab is closed when you close it through the close button. When you drag a tab into a new window, the tab is removed from the RadTabbedFormControl.Tabs collection and become a stand-alone tabbed form. In both cases, the tab is removed from the RadTabbedFormControl.Tabs collection and it is expected the TabRemoving and TabRemoved events to get triggered. 

If you do not want to be able to drag tabs from the tabbed form you can specify its ItemDragMode:

this.radTabbedFormControl1.ItemDragMode = TabItemDragMode.None;

However, if you want to be able to close tabs as well as drag them out the tabbed form and know which is the reason for firing the TabRemoving\TabRemoved events I can suggest using the RadTabbedFormDragDropService in order to help determine the reason. Please refer to the following code snippet:

RadTabbedFormDragDropService dragDropService = this.TabbedFormControl.TabbedFormControlElement.ItemDragService;
dragDropService.TabbedFormCreating += DragDropService_TabbedFormCreating;
bool tabIsDragged = false;
private void DragDropService_TabbedFormCreating(object sender, TabbedFormCreatingEventArgs e)
{
    tabIsDragged = true;
}

private void RadTabbedFormControl1_TabRemoved(object sender, RadTabbedFormControlEventArgs e)
{
    if (tabIsDragged)
    {
        Console.WriteLine("tab is dragged");
    }
    else
    {
        Console.WriteLine("tab is closed");
    }
    tabIsDragged = false;
}

I hope this information helps. Should you have further 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
n/a
Top achievements
Rank 1
Veteran
answered on 14 Jan 2021, 10:05 PM
Excellent work Nadya. Thank you!
Tags
TabbedForm
Asked by
n/a
Top achievements
Rank 1
Veteran
Answers by
Nadya
Telerik team
n/a
Top achievements
Rank 1
Veteran
Share this question
or