|
-
Nov 29th, 2000, 09:38 AM
#1
Thread Starter
Lively Member
With this code, I've made a control at runtime.
Set btnObj = Controls.Add("VB.ComboBox", sControlName)
With btnObj
.Visible = True
.Width = 2000
.Top = 210 + (i * 350)
.Left = 5500
.ForeColor = vbBlack
.Text = ""
End With
Now I want to remove it. So I thought to set it equal to Nothing:
Set btnObj = Nothing
The problem is, that the control is still on my form.
How can I realy remove it?
-
Nov 29th, 2000, 09:46 AM
#2
Hyperactive Member
Just a thought .
Change it's visible property and then set it to nothing .
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 29th, 2000, 09:49 AM
#3
New Member
-
Nov 29th, 2000, 10:14 AM
#4
Thread Starter
Lively Member
The Unload solution doesn't seems to work.
first I've set the visible property to false
and then I set it on nothing.
When I want to add a new control with te same name as the one I deleted, I get an error which said "Object with this name already exists".
So it seems that the 'Nothing' not realy destroys the object.
Some solution?
-
Nov 29th, 2000, 10:16 AM
#5
Fanatic Member
As it is a Collection you should have access to the Remove method. i.e. Controls.Remove sControlName
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 29th, 2000, 10:18 AM
#6
Frenzied Member
Try this api call!
Code:
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub RemoveMe(Handle As Long)
DestroyWindow Handle
End Sub
'usage:
'RemoveMe btnObj.hWnd
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 29th, 2000, 04:53 PM
#7
Controls has a property called Remove.
Code:
Controls.Remove ("sControlName")
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
|