Delete a text box

Hi,

Is it possibe to delete a textbox from a form programmtaically?

I was looking for something like

textbox1.remove

but could not find it.

Daz
yo_daz_ukAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Try this

        TextBox1.Dispose()

Fernando
0
sr101880Commented:
yes, it's : textbox1.dispose

let me know if you have any problems.
0
Fernando SotoRetiredCommented:
Yes sr101880 that is what I told yo_daz_uk to do.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

sr101880Commented:
sorry, your comment wasn't on my screen when I hit submit.  No hard feelings. :-)  yo_daz_uk , Please disregard my comment.
0
Fernando SotoRetiredCommented:
No problem sr101880 and you have a great day. ;=)
0
tolgaongCommented:
If you want to remove the textbox from the form but to use its properties anyway for any reason.
use:
 Me.Controls.Remove(TextBox1)
=> This line is valid if the textbox is placed on the form.
If it is placed on a panel or groupbox or any other container use that container's controls array

But if you want to delete the textbox not only from the form but also from the memory, then use the method that FernandoSoto and sr101880 propesed.
0
yo_daz_ukAuthor Commented:
Thanks its in a hast table is the also a way to empty a hash table ?
0
Fernando SotoRetiredCommented:
Hi yo_daz_uk;

This code will delete all the TextBox's in the HashTable and delete all the elements in the HashTable.

        ' ht is the HashTable with TextBox.s in its array
        For Each obj As Object In ht
            Dim tb As TextBox
            ' Cast objects in the HashTable to TextBox's
            tb = CType(obj.Value, TextBox)
            ' Delete the TextBox's
            tb.Dispose()
        Next

        ' Delete all the elements in the HashTable
        ht.Clear()


Fernando
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yo_daz_ukAuthor Commented:
Thanks fernado, i knew it was something basic i just couldnt find the answer!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.