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

Responding to Double-Click and Right Click on Dynamic Tabs

2 Answers 135 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.
Marc
Top achievements
Rank 2
Marc asked on 26 Dec 2008, 06:32 PM
I am having trouble finding a solution to this need.  I have a radTabStrip on a form with one tab created at Design time.  This one tab is [Add New] used for adding other tabs.  I need to respond to both Right Click (mousedown) and Double click on the Dynamically created tabs.  This is no problem on the tab created at design time because it is easy to create the event but can't seem to create an event for the dynamic tabs.

The examples I found in the documentation (responding to right click and double click) only deal with design time tabs.  When I use the mouse down and click events for the RadTabStrip itself it respond to clicks on more than just the tabs, but on the control itself.

Any help (guidance) would be appreciated.

I am using VB.net in VS2008.

BTW:  Your controls are great!

2 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 2
answered on 26 Dec 2008, 08:24 PM
Found a solution.

I copied the following two subs from your Right Click and Double Click example:

 

    Private Sub TabItem_DoubleClick(ByVal sender As ObjectByVal e As System.EventArgs)  
 
        Dim ti As TabItem = DirectCast(sender, TabItem)  
        'do something  
        MsgBox(ti.Name)  
 
    End Sub 
 
    Private Sub TabItem_MouseDown(ByVal sender As ObjectByVal e As MouseEventArgs)  
 
        If e.Button = MouseButtons.Right Then 
            Dim ti As TabItem = DirectCast(sender, TabItem)  
            'do something  
            MsgBox(ti.Name)  
        End If 
    End Sub 
 
 

Then added the AddHandler code after creating each new Tab.

t = New Telerik.WinControls.UI.TabItem("New Tab")  
t.Name = "Newest Tab" 
radTabStrip.Items.Insert(0, t)  
 
'set the event handler for the new tab  
AddHandler t.MouseDown, AddressOf TabItem_MouseDown  
AddHandler t.DoubleClick, AddressOf TabItem_DoubleClick  
 

PS:  Forgot to mention your controls are great!


0
Martin Vasilev
Telerik team
answered on 30 Dec 2008, 07:13 AM
Hello Marc,

Thank you for sharing your code with us.

I am glad that you have found solution for your case and that you find our tools great! I have reviewed your code and it sems ok to me.

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

Sincerely yours,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Marc
Top achievements
Rank 2
Answers by
Marc
Top achievements
Rank 2
Martin Vasilev
Telerik team
Share this question
or