Results 1 to 22 of 22

Thread: Hmm dynamic form problem *RESOLVED*

Threaded View

  1. #1

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Hmm dynamic form problem *RESOLVED*

    ok. I have a tabcontrol with a couple dynamiclly created tabs with dynamiclly added controls on them. I am writing a Tear function the when you write click a tab header, you get a popup menu with the oiption to Tear. When selected a new form appears that becomes a torn out version of the ontrol that were on the tab( Get what I mean?). First time its fine on a control with 1 control. But do it again and 2 windows appear. again and 3 windows appear.

    But that is not all. With more than 1 control, it ceates a new form for each one.

    Oh and when I place the ocntrol form the tab onto the new form, they disappear from the tab. Ok, so I will make the tab invisible until layet. But no, you cant change the visiblity ot tabs either!

    Argh.

    Anyone got a clue. Here is the relevant Tear code

    VB Code:
    1. Private Sub tabClient_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tabClient.MouseDown
    2.  
    3.         Dim tab As New TabPage()
    4.         Dim x As Integer
    5.         Dim rect As Rectangle
    6.         Dim ctl As Control
    7.         Dim holdctl As Control
    8.  
    9.         pos.X = e.X
    10.         pos.Y = e.Y
    11.         If e.Button = MouseButtons.Right Then ContextMenu1.Show(tabClient, pos)
    12.         AddHandler MenuItem1.Click, AddressOf Tear
    13.     End Sub
    14.  
    15.     Private Sub Tear(ByVal sender As Object, ByVal e As EventArgs)
    16.  
    17.         Dim tab As New TabPage()
    18.         Dim x As Integer
    19.         Dim rect As Rectangle
    20.         Dim ctl As Control
    21.  
    22.         For x = 0 To tabClient.TabCount - 1
    23.             rect = tabClient.GetTabRect(x)
    24.             If rect.Contains(pos) Then
    25.                 Dim test As New Form()
    26.                 AddHandler test.Closing, AddressOf FormClose
    27.                 For Each ctl In tabClient.TabPages(x).Controls
    28.                     test.Controls.Add(ctl)
    29.                 Next
    30.                 test.Show()
    31.                 Exit For
    32.             End If
    33.         Next
    34.     End Sub
    Last edited by Cander; Jun 3rd, 2003 at 03:26 PM.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width