Solved

Removing a control

Posted on 2004-09-18
5
172 Views
Last Modified: 2010-04-23
Hi

I've added a button during runtime.
But when I try to remove it again, it won't go away

Code:

        Dim btnhuidig As Button = sender
        If txthuidig.Text Like "*@*.*" Then
            mstrEmail(1, txthuidig.Tag) = txthuidig.Text
            Me.Controls.Remove(btnhuidig)
        Else

I've tried also with Me.Refresh
Anyone has an idea?
0
Comment
Question by:Schuppex
5 Comments
 

Expert Comment

by:cheese_ontoast
Comment Utility
Can you paste the code that created the button and maybe a bit more code to do with the 'sender' variable?

Otherwise the removal of a runtime created button should be easy enough...

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myNewButton As New Button
        myNewButton.Name = "btnTest"
        myNewButton.Text = "TEST"
        Me.Controls.Add(myNewButton)
        AddHandler myNewButton.Click, AddressOf Me.NewButtonClick
    End Sub

    Private Sub NewButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Controls.Remove(sender)
    End Sub
0
 
LVL 8

Accepted Solution

by:
wguerram earned 125 total points
Comment Utility
Did you check if it is getting in the if condition?.

I tried and it works.

Try this without the conditions:

        Dim btnhuidig As Button = sender
        Me.Controls.Remove(sender)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now