Textbox Click Event needed.

A

ally

I am working with a panel of preconfigured textbox controls arranged
in rows and columns. They are programmatically updated based on
changing data from an external data collector device.

I would like to add a textbox_ click event property to one specific
column, of this group, which I intend to use as a trigger to prompt
for additional user supplied information. I don't see a way to do
this in the textbox properties, so is there is some convenient way to
add this property to textbox controls? If so, could you provide a
code snippet example of how to do this?

Thanks,
Ally
 
Y

Yuk Tang

ally wrote in news:[email protected]:
I am working with a panel of preconfigured textbox controls
arranged in rows and columns. They are programmatically updated
based on changing data from an external data collector device.

I would like to add a textbox_ click event property to one
specific
column, of this group, which I intend to use as a trigger to
prompt for additional user supplied information. I don't see a
way to do this in the textbox properties, so is there is some
convenient way to add this property to textbox controls? If so,
could you provide a code snippet example of how to do this?

Got focus?
 
C

Cerebrus

Hi,

Events and Properties are two separate things. It might help to
identify what exactly you want to add.

If I understand you correctly, then your problem can simply be solved
by making a common EventHandler for all the TextBoxes in that column,
and wiring the Click / MouseDown event to this EventHandler. For
instance :

Private Sub MySpecialTextColumnHandler(Byval sender as Object, Byval e
as EventArgs) Handles Text1.Click, Text2.Click, Text3.Click....
' First identify the Textbox that was clicked
Dim txt as TextBox = DirectCast(sender, TextBox)
' Take necessary actions...
:
:
End Sub

If you need to take special actions depending on the MouseButton that
was clicked, then wire up the handler to the MouseDown events instead.

HTH,

Regards,

Cerebrus.
 
A

ally

Hi,


Events and Properties are two separate things. It might help to
identify what exactly you want to add.


If I understand you correctly, then your problem can simply be solved
by making a common EventHandler for all the TextBoxes in that column,
and wiring the Click / MouseDown event to this EventHandler. For
instance :

Private Sub MySpecialTextColumnHandler(Byval sender as Object, Byval e
as EventArgs) Handles Text1.Click, Text2.Click, Text3.Click....
' First identify the Textbox that was clicked
Dim txt as TextBox = DirectCast(sender, TextBox)
' Take necessary actions...
:
:
End Sub

If you need to take special actions depending on the MouseButton that
was clicked, then wire up the handler to the MouseDown events instead.

HTH,

Regards,

Cerebrus.
Thanks your for your help! You've provided a way to do what I'm
after, but I don't understand how to identify which textbox triggered
the event.

Using your example, with three textboxes as the underlying controls
for example, how would you go about identifying which one called the
click event?



Ally
 
H

Herfried K. Wagner [MVP]

I would like to add a textbox_ click event property to one specific
column, of this group, which I intend to use as a trigger to prompt
for additional user supplied information. I don't see a way to do
this in the textbox properties, so is there is some convenient way to
add this property to textbox controls? If so, could you provide a
code snippet example of how to do this?

You may want to handle the control's 'Enter' or 'GotFocus' event.
 
C

Cerebrus

Hi,

It depends on what is the distinguishing property of the textboxes. You
could check the Name property or the Tag property (which you have to
set beforehand), for instance. In the sample code I provided above,
before "Take necessary actions", you could run a check in this way :

Select case txt.Tag
Case "Absurd"
' Do something
Case "Wierd"
' Do something
Case "Crazy"
' Do something
End Select

Hope this helps,

Regards,

Cerebrus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top