Programatically remove controls from a winform tab page


Author
Message
Michael R Poirier
Michael R Poirier
StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)StrataFrame Beginner (11 reputation)
Group: StrataFrame Users
Posts: 9, Visits: 131
I have code that adds controls to a tab page - and the code below attempts to remove them.  All of the labels are removed - but the text boxes and combo boxes are not.  I even tried unbinding the text boxes and combo boxes - still not removed.

Any help is appreciated - code to remove controls:

Private Sub clearconditiontab()

Dim sftextbox As MicroFour.StrataFrame.UI.Windows.Forms.Textbox

Dim sfcombobox As MicroFour.StrataFrame.UI.Windows.Forms.ComboBox

For Each locontrol As Control In Me.TBP_Condition.Controls

If locontrol.GetType() Is GetType(MicroFour.StrataFrame.UI.Windows.Forms.ComboBox) Then

sfcombobox = locontrol

sfcombobox.BusinessObject = Nothing

sfcombobox.BindingField = Nothing

End If

If locontrol.GetType() Is GetType(MicroFour.StrataFrame.UI.Windows.Forms.Textbox) Then

sftextbox = locontrol

sftextbox.BusinessObject = Nothing

sftextbox.BindingField = Nothing

End If

Me.TBP_Condition.Controls.Remove(locontrol)

Next

Me.TBP_Condition.Refresh()

End Sub


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Michael R Poirier - 15 Years Ago
Greg McGuffey - 15 Years Ago
Michael R Poirier - 15 Years Ago
Greg McGuffey - 15 Years Ago
Michael R Poirier - 15 Years Ago
                         Glad you go it working.
Greg McGuffey - 15 Years Ago
                             Here is my code ------------------------------------------- For Each...
- 13 Years Ago
                                 You are removing the items from the collection you are enumerating....
Trent L. Taylor - 13 Years Ago
                                 I guess if you enumerate your controls, as soon as you remove one of...
Ivan George Borges - 13 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search