473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Textbox MouseDown

Is there a way to modify all textboxes on a form so that when you
click on any of them you process the SelectAll() function.

For exaple, let's say I've created a form with 30 textboxes. These
textboxes when clicked on, will select all of the text inside of them
using the textbox.selectall(). I'm hoping to do this without creating
30 different Subs. How do I do it?

Aug 29 '07 #1
2 2998
On Aug 29, 5:19 pm, "lmeff...@gmail.com" <lmeff...@gmail.comwrote:
Is there a way to modify all textboxes on a form so that when you
click on any of them you process the SelectAll() function.

For exaple, let's say I've created a form with 30 textboxes. These
textboxes when clicked on, will select all of the text inside of them
using the textbox.selectall(). I'm hoping to do this without creating
30 different Subs. How do I do it?
Ok, I found a way, but it's still pretty lengthy.
I merely used a single mousedown event for one textbox and added a few
textboxes to the handles and then proceeded to use the sender.

Private Sub uione_MouseDown_
(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) _
Handles uione.MouseDown, _
uitwo.MouseDown, _
uithree.MouseDown, _
uifour.MouseDown
sender.SelectAll()
End Sub

I kind of want to avoid that cause it seems a little slow and I'm
wanting to streamline the code. But if that's the way to do it, then
so be it.

Aug 29 '07 #2
why not just have each of the textboxs' Click events go to the same function,
ex, if the textboxes are in an array

For Each txt As TextBox In arrInput

AddHandler txt.Click, AddressOf ClickEventHere

Next

then in the click event, cast Sender to a textbox and select all...

Private Sub ClickEventHere(ByVal sender As Object, ByVal e...)

Dim txt As TextBox = DirectCast(sender, TextBox)

txt.SelectAll()

End Sub

hope this helps

--
-iwdu15
Aug 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JJ | last post by:
Hi All, I need to create a MouseDown event for a picture box . Am I doing the following right? pictureBox.MouseDown += new System.WinForms.MouseEventHandler(pictureBox_MouseDown) Then
2
by: Rob | last post by:
How can I fix the following warning warning BC40004: sub 'MouseDown' conflicts with event 'MouseDown' in the base class 'Control' and so should be declared 'Shadows'. This warning appears...
12
by: Gene Hubert | last post by:
How do I make a TextBox behave like the address bar in IE? That is... If focus is not on the tb, select all text if clicking on the tb or tabbing into the tb. Clicking again deselects the text...
7
by: Itar | last post by:
I'm having a problem supressing characters in a text box. I only want alpha numeric characters (no special chars). I can handle the TextBox_KeyPress event to supress the invalid characters when...
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
8
by: cj | last post by:
I asked this question a couple of days ago but am just now looking at it again. I used to use the textbox gotfoucs event to have all the text in the textbox selected when it gotfocus. That...
5
by: ally | last post by:
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...
3
by: sunny076 | last post by:
Hi, I am wondering if any of you Javascript experts can enlighten me on which event to call. The use situation is that the tetxbox field is populated from the DB and the add/update and delete...
3
by: Patrick [MSFT] | last post by:
Let me preface this with the goal I'm trying to achieve is mimic a feature of another language (Dexterity used by Microsoft Dynamics) and so while a filling a drop down list is a workable solution...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.