473,473 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Deleting one of many dynamically created textbox on click .Net

13 New Member
Any help would be greatly appreciated. My problem is as follows:

I have a program that dynamically creates any control (picture boxes, text boxes etc) on a panel, i want to be able to delete these controls by clicking on a 'Trash' button and then on the control i wish to delete. Try as i might i cant do it!

The relevant code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4. 'This creates the textboxes and their handlers (i think iv'e done the handlers correctly...but i might not have)
  5.  
  6.  If Tool = "Text" Then
  7.  
  8.             'define varibles
  9.             intelement = intelement + 1
  10.             CursorOffset = Windows.Forms.Cursor.Position
  11.             intheight = (Me.Height - Panpro.Height) / 2
  12.             intwidth = (Me.Width - Panpro.Width) / 2
  13.             sintxtsize = txtsize.Text
  14.  
  15.             'make space
  16.             ReDim Preserve dynlabel(intelement)
  17.  
  18.             'create new label and define propeties
  19.             Me.Controls.Add(dynlabel(intelement))
  20.             dynlabel(intelement) = New TextBox
  21.             dynlabel(intelement).Location = New Point((CursorOffset.X - intwidth), (CursorOffset.Y - intheight))
  22.             dynlabel(intelement).Parent = Panpro
  23.             dynlabel(intelement).Text = "TYPE HERE"
  24.             dynlabel(intelement).Tag = intelement
  25.  
  26.             AddHandler dynlabel(dynlabel(intelement).Tag).MouseClick, AddressOf textbox_click
  27.  
  28.         End If
  29.  
  30.  
  31. 'And this is the handler
  32.  
  33.  Private Sub textbox_click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  34.  
  35.         If Tool = "KILL" Then
  36.             Me.Controls.Remove(dynlabel(intelement))
  37.         End If
  38.  
  39.  
  40.     End Sub
  41.  
  42.  
Most likely i have tried to do it a stupid way, but any help would be greatly appreciated.
Aug 20 '07 #1
1 1192
Alcestis
13 New Member
I could really do with some help on this.
Aug 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Gelios | last post by:
Hello all! I have a Windows.Forms code where I dynamically created controls. How can I access to properties from event handler? For example: createSomeControls() { TextBox textBox = new...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
2
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
5
by: Jason MacKenzie | last post by:
I'm trying to capture the text property of a dynamically created textbox on the screen.. I can't get this simple example to work. I get "Object Reference Not set to instance....." on the...
2
by: Radu | last post by:
Hi. I have a page with the following html: __________________________________________________________ <h1>Dynamic Controls Test</h1> <hr /> <asp:TextBox ID="txtProduct1" Text="txtProduct 1"...
0
by: ahmadbaseet | last post by:
Hello all I am new to VB.NET. I am trying to create dynamically objects and giving them the event handles. Something like this Dim NewTab As New TabPage Dim NewTextBox As New TextBox Dim...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.