[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to detect events on a textbox array created programaticly?

Posted on 2010-09-22
2
Medium Priority
?
437 Views
Last Modified: 2012-08-13
I have cretaed an array of textbox objects programaticly on Visual Basic 2008.

Now I need to detect when somebody clicks on one of those textboxes.

Can you Help me pls?
0
Comment
Question by:RUIDEOLIVEIRA
[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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 33734095
As you create each TextBox use AddHandler() to "wire up" the Click() event to a handler.

Make sure you're using the correct event....not sure if you literally want the Click() event or if you actually need the MouseDown() or the GotFocus() events?

At any rate, you can follow this example and adjust the event and signature as necessary:
Public Class Form1

    Private TextBoxes As New List(Of TextBox)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 1 To 10
            Dim tb As New TextBox
            tb.Name = "MyTextBox" & i
            tb.Text = "TextBox #" & i
            AddHandler tb.Click, AddressOf TB_Click
            FlowLayoutPanel1.Controls.Add(tb)
            TextBoxes.Add(tb)
        Next
    End Sub

    Private Sub TB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim TB As TextBox = CType(sender, TextBox)
        MessageBox.Show("TextBox Name: " & TB.Name & vbCrLf & "TextBox Text: " & TB.Text)
    End Sub

End Class

Open in new window

0
 

Author Closing Comment

by:RUIDEOLIVEIRA
ID: 33736254
The problem is completely solved.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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