Solved

Removing a control

Posted on 2004-09-18
5
177 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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