473,466 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Selected Text

I am wanting to select all of the text in a textbox control when the enters
the control I thought the "selectionLength" property and setting it to the
length of the value in the textbox. I also used the "entered" event. Nothing
happens when I enter the control. The code (below) executes, but nothing is
highlighted like is was selected. Am I not using the correct property?

Thanks in advance for your assistance!!!!


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 19 '05 #1
3 11017
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.Text.Length

TextBox1.Focus()

HTH
Kalpesh

"Jim Heavey" <Ji*******@hotmail.com> wrote in message news:<3f********@corp.newsgroups.com>...
I am wanting to select all of the text in a textbox control when the enters
the control I thought the "selectionLength" property and setting it to the
length of the value in the textbox. I also used the "entered" event. Nothing
happens when I enter the control. The code (below) executes, but nothing is
highlighted like is was selected. Am I not using the correct property?

Thanks in advance for your assistance!!!!


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Nov 19 '05 #2
"Jim Heavey" <Ji*******@hotmail.com> schrieb
I am wanting to select all of the text in a textbox control when the
enters the control I thought the "selectionLength" property and
setting it to the length of the value in the textbox. I also used
the "entered" event. Nothing happens when I enter the control. The
code (below) executes,
Hmm..pretty fast code... ;-)
but nothing is highlighted like is was
selected. Am I not using the correct property?


TextBox1.SelectAll()

works for me. It doesn't help when entering the texbox using the mouse
because the selection is set after the textbox has been entered.


--
Armin

Nov 19 '05 #3
Hello,

"Jim Heavey" <Ji*******@hotmail.com> schrieb:
I am wanting to select all of the text in a textbox control when the enters the control I thought the "selectionLength" property and setting it to the length of the value in the textbox. I also used the "entered" event. Nothing happens when I enter the control. The code (below) executes, but nothing is highlighted like is was selected. Am I not using the correct property?


Where is the code?

Untested: Use this class instead of the standard windows forms textbox:

\\\
Public Class MyTextBox
Inherits TextBox

Private Sub MyTextBox_GotFocus( _
ByVal sender As Object, _
ByVal e As System.EventArgs _
) Handles MyBase.GotFocus
Me.SelectAll()
End Sub
End Class
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #4

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

Similar topics

7
by: Razzbar | last post by:
I have a textarea and some buttons. The buttons apply functions to the text the user selects, i.e. the good old "wrap with a tag" thing we all have seen in 100 different editors. Trouble is,...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
4
by: Mark Kolber | last post by:
I did a little searching on this but couldn't find an answer... On my website, I have a section of stories (www.midlifeflight.com/stories) There are different stores on different pages that are...
1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
4
by: acni | last post by:
I have the following peice of code to try and send an email to selected contacts in my form.The problem is this line: StrStore = DLookup("", "qrySelectEmail", "??????") This looks up the email...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
6
by: George | last post by:
Hi all, How can I get the value stored from the selected item and subitems of a listview? Thanks in advance, George
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
4
by: coldfusionstudent | last post by:
i wish to show/appear and dissappear text box based on a the drop down item selected. what do i have to add? thanks under Comm_DEV drop down selection.
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.