Solved

Removing a control

Posted on 2004-09-18
5
174 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
ID: 12091633
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
ID: 12092823
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

772 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