Responding to Double-Click and Right Click on Dynamic Tabs

3 posts, 0 answers
  1. Marc
    Marc avatar
    21 posts
    Member since:
    Dec 2008

    Posted 26 Dec 2008 Link to this post

    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. Marc
    Marc avatar
    21 posts
    Member since:
    Dec 2008

    Posted 26 Dec 2008 Link to this post

    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!


  3. UI for WinForms is Visual Studio 2017 Ready
  4. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 30 Dec 2008 Link to this post

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