Solved

Removing a control

Posted on 2004-09-18
5
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

707 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