Visual Basic Development Bookmark and Share   
 Home > Visual Basic IDE > How do I remove control from form
 

How do I remove control from form

Have been trying to use Delete key, as in VB6, but nothing happening

dpowning  Thursday, November 19, 2009 4:48 AM


Public Class Form1
    Dim TBox As New TextBox

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'This add a control to the form
        Me.Controls.Add(TBox)

        'this remove a control from the form
        Me.Controls.Remove(TBox)

    End Sub
End Class
Crazypennie  Friday, November 20, 2009 2:47 AM
You mean at design time? You should be able to click on the control and press Delete. I can't think why it wouldn't work.

If it really refuses, you can dig through the code and hunt down the location where it is created in the automatically generated code. If you delete that and try to run, you'll get error messages showing you everywhere else the control is referenced. Delete those and you should be ready to go.

But I wouldn't do all of that for a small example, only a big program where you don't want to lose a lot of work. For a small example, I'd try starting a new project and see if the problem continues.

Rod
www.vb-helper.com
Rod Stephens  Saturday, November 21, 2009 3:06 PM


Public Class Form1
    Dim TBox As New TextBox

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'This add a control to the form
        Me.Controls.Add(TBox)

        'this remove a control from the form
        Me.Controls.Remove(TBox)

    End Sub
End Class
Crazypennie  Friday, November 20, 2009 2:47 AM
You mean at design time? You should be able to click on the control and press Delete. I can't think why it wouldn't work.

If it really refuses, you can dig through the code and hunt down the location where it is created in the automatically generated code. If you delete that and try to run, you'll get error messages showing you everywhere else the control is referenced. Delete those and you should be ready to go.

But I wouldn't do all of that for a small example, only a big program where you don't want to lose a lot of work. For a small example, I'd try starting a new project and see if the problem continues.

Rod
www.vb-helper.com
Rod Stephens  Saturday, November 21, 2009 3:06 PM

You can use google to search for other answers

Custom Search

More Threads

• Tabbed Web Browser : Making it navigate
• difference while executing project on the server thru my computer and my friends pc
• Quckfind
• Function description(documentation) not working in VB.NET?
• DataAdapter fail to update
• ODBC Connection to Oracle DB
• Region/Xml-comment Text Color Bug
• Creating a solution with multiple projects
• How to retrieve and store BFILE datas
• Running 2 instances of VS 2005 professional