|
-
Sep 25th, 2008, 01:57 PM
#1
Thread Starter
Fanatic Member
[2008] adding/removing user controls
Hokay, here's what I am trying to do:
I created a simple user control with a label and a textbox. No public properties yet, no methods, no functions.
In my main form, there is a method called "UploadFile". This method executes when the user uploads a file. This method is part of a threadpool, so two methods might occur simultanously. My goal is everytime this method is run, it creates an instance of the usercontrol (will probabaly put a progress bar in there and everything), and add it on the main form.
I HAVE NO PROBLEM ADDING IT TO THE FORM.
Here is my method:
In the starting of my method I have the following:
vb.net Code:
Private Sub addProgress()
Dim _found As Boolean = False
Dim pre As uploadprogress = Nothing
Dim preLocation As Integer
Dim ctl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order.
Do Until ctl Is Nothing
'Use ctl here.
If TypeOf (ctl) Is uploadprogress Then
preLocation = ctl.Location.Y
_found = True
pre = ctl
End If
ctl = Me.GetNextControl(ctl, True) 'Get the next control in the tab order.
Loop
If _found And pre IsNot Nothing Then
u_view = New uploadprogress
Me.Controls.Add(u_view)
u_view.BringToFront()
u_view.Location = New Point(6, preLocation + pre.Height)
Else
u_view = New uploadprogress
Me.Controls.Add(u_view)
u_view.BringToFront()
u_view.Location = New Point(6, 119 + 91)
End If
End Sub
u_view is declared as "private withevents as [usercontrol class name]"
Okay so this adds the usercontrol fine! However, when my UploadFile Method ENDS, I want to remove the usercontrol. My main form automatically grows when a usercontrol is added to the bottom, so I would like to shrink it when it is removed..
but my question is.. how do I remove this user control.
-
Sep 25th, 2008, 02:02 PM
#2
Frenzied Member
Re: [2008] adding/removing user controls
Where is the upload method? is it in the user control or the form. Basically a user control behaves like any other class, IE it can be destroyed after use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|