Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

A Little Help?

 

ok the new function works, but i cant get the rename function to work, any ideas?

 

 

 


   Private Sub tabControl1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles TabControl1.MouseDown
       If e.Button = MouseButtons.Right Then
           Dim i As Integer = 0

           For i = 0 To tabControl1.TabCount - 1
               If tabControl1.GetTabRect(i).Contains(e.X, e.Y) Then
                   tabControl1.SelectedIndex = i
                   Exit For
               End If
           Next
           Dim cMenu As ContextMenu
           Dim Menus(2) As MenuItem
           Dim intKey As Integer

           Menus(0) = New MenuItem("&New Tab", AddressOf AddTab)
           Menus(1) = New MenuItem("&Edit Tab", AddressOf RenameTab)
           Menus(2) = New MenuItem("&Delete")

           cMenu = New ContextMenu(Menus)
           cMenu.Show(sender, New Point(e.X, e.Y))
           'display contextmenu.. 
       End If
   End Sub

   Private Sub AddTab(ByVal Sender As System.Object, ByVal e As System.EventArgs)
       Dim MyNewTabPage As New TabPage
       With MyNewTabPage
           .Text = "New Page"
       End With
       TabControl1.TabPages.Add(MyNewTabPage)

   End Sub

   Private Sub RenameTab(ByVal Sender As System.Object, ByVal e As System.EventArgs)
       TextBox2.Text = DirectCast(Sender.Parent, ContextMenu).SourceControl.ToString
       MsgBox("rename")
       With DirectCast(Sender.Parent, ContextMenu).SourceControl
           .Text = "blah"
       End With
   End Sub

Edited by modtheplanet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...