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

Cancel Mouse click

2 Answers 89 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
guillaumeGL
Top achievements
Rank 2
guillaumeGL asked on 26 Nov 2009, 03:25 PM
Hello,

Is there a way to cancel user's click on tab ?
In my situation, I need to only allow users to use F1-F12 keys to open the tabs, and I only want to show a MessageBox after a click.

Disabling the tabs partially resolve this problem, but I completely lose the click/mouse-click events for the MessageBox.

Best Regards,
Guillaume Lebeau
Adiial

2 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 01 Dec 2009, 02:39 PM
Hello Guillaume,

Thank you for writing. RadTabStrip does not support escaping the mouse click event out of the box. However you can implement such a scenario by using TabSelecting and MouseDown events. Please, consider the following code-block:

TabItem _previosTab;
 
void radTabStrip1_MouseDown(object sender, MouseEventArgs e)
{
    TabItem clickedItem = this.radTabStrip1.ElementTree.GetElementAtPoint(e.Location) as TabItem;
    if (clickedItem != null && _previosTab != null)
    {
        this.radTabStrip1.TabSelecting -= radTabStrip1_TabSelecting;
 
        this.radTabStrip1.SelectedTab = _previosTab;
       
 
        this.radTabStrip1.TabSelecting += radTabStrip1_TabSelecting;
 
        MessageBox.Show("Tab selecting was prevented!");
    }
      _previosTab = null;
}
 
void radTabStrip1_TabSelecting(object sender, TabCancelEventArgs args)
{
    _previosTab = this.radTabStrip1.SelectedTab as TabItem;
}

Do not hesitate to contact me again if you have any other questions.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
guillaumeGL
Top achievements
Rank 2
answered on 14 Dec 2009, 12:32 PM
Thank you !!

Your solution works great.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
guillaumeGL
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
guillaumeGL
Top achievements
Rank 2
Share this question
or