473,382 Members | 1,362 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,382 software developers and data experts.

textbox selecting text - no highlight

I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark
Nov 21 '05 #1
5 7230
Just do Text1.SelectAll()

<ma*****@yahoo.com> wrote in message
news:nq********************************@4ax.com...
I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark
Nov 21 '05 #2
Hi,

The textbox will not show the selection when textbox doesnt have
focus unless you set the hideselection property to true.
http://msdn.microsoft.com/library/de...ctiontopic.asp

Ken
---------------
<ma*****@yahoo.com> wrote in message
news:nq********************************@4ax.com...
I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark
Nov 21 '05 #3
i got problem ...i don't want highlighting i'm using gdi ...how do i et
get ridded of unwanted highlighting?

Dim txthelp As New TextBox
With txthelp
.Parent = Me
.SelectionStart = 0
.SelectionLength = .Text.Length
.BackColor = Color.White
.Dock = DockStyle.Fill
.WordWrap = True
.Multiline = True
.ScrollBars = ScrollBars.Vertical
.ReadOnly = True
.Text = "How to play MasterMind game." & vbCrLf & _
"The object of this game is to guess the sequence of four (4) coloured
pegs the computer has selected at random from the circled colours on the
right side field. " & vbCrLf & vbCrLf & _
"The computer chooses a secret combination of coloured pegs and can use
a colours more than once in the combination." & vbCrLf & _
"The computer pegs are hidden behind logo." & vbCrLf & vbCrLf & _
"You can have up to ten (10) guesses." & vbCrLf & _
"There are up to eight (8) Coloured pegs."
end with
regards

Ken Tucker [MVP] wrote:
Hi,

The textbox will not show the selection when textbox doesnt have
focus unless you set the hideselection property to true.
http://msdn.microsoft.com/library/de...ctiontopic.asp

Ken
---------------
<ma*****@yahoo.com> wrote in message
news:nq********************************@4ax.com.. .
I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark


Nov 21 '05 #4
I understand that, but this is when the textbox GETS the focus that
its not highlighted. The user clicks the mouse in the text field,
which runs the code I have documented below, yet the selection is not
highlighted.

Thanks,
Mark

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<eU**************@TK2MSFTNGP12.phx.gbl>...
Hi,

The textbox will not show the selection when textbox doesnt have
focus unless you set the hideselection property to true.
http://msdn.microsoft.com/library/de...ctiontopic.asp

Ken
---------------
<ma*****@yahoo.com> wrote in message
news:nq********************************@4ax.com...
I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark

Nov 21 '05 #5
thank Mark, i got no highlighting using selectedtext.

Mark wrote:
I understand that, but this is when the textbox GETS the focus that
its not highlighted. The user clicks the mouse in the text field,
which runs the code I have documented below, yet the selection is not
highlighted.

Thanks,
Mark

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<eU**************@TK2MSFTNGP12.phx.gbl>...

Hi,

The textbox will not show the selection when textbox doesnt have
focus unless you set the hideselection property to true.
http://msdn.microsoft.com/library/de...ctiontopic.asp

Ken
---------------
<ma*****@yahoo.com> wrote in message
news:nq********************************@4ax.com. ..
I'm very confused. I'm trying to automatically select the text when
my textbox gets the focus. This is typically when the user has
clicked the mouse in the field.

This is the code I have in the Text1_GotFocus event:

Text1.SelectionStart = 0
Text1.SelectionLength = Text1.Text.Length

However, the text does not get highlighted. It appears to be the
"selectedtext" though because immediately after that I have a
Console.Writeline call printing text1.selectedtext and it is the
entire field. I just can't get it to highlight. Any ideas ????

Mark


Nov 21 '05 #6

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

Similar topics

1
by: orekinbck | last post by:
Hi There I have a datagrid whose main purpose in life is to provide a nice way for users to make a single choice from a list. The grid is read only, single row select and has its data source as...
4
by: melanieab | last post by:
Hi, I need to write something so that when a textbox is entered (this is for a touchscreen), all the text in that textbox is selected (highlighted) and new keystrokes replace the old text. Help!...
3
by: Harry Simpson | last post by:
I've got a server-side textbox that receives the focus when the page loads. It has the text "Refine your Search" in the textbox. Obviously the user needs to highlight the "Refine your Search"...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
4
by: Brett | last post by:
I have a textbox with a heigth of 384. I put a lot of text into it and must scroll down to see it all. When I do Ctrl + A, it doesn't highlight all of the text. I have to manually drag my mouse...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
2
by: Abubakar | last post by:
Hi, In a normal Windows.Forms.TextBox control, I want to be able to select a text (ie highlight, this is by default possible) and than be able to drag that text through my mouse pointer to another...
2
by: JJ | last post by:
I have a textbox that is used to insert some html code. I want to highlight errors in the code, possibly by selecting the text. Is it possible to highlight/select areas of a textbox...
7
by: sphinney | last post by:
I have a datasheet style form with textbox (MyTextBox) that has the Text Format property set to "Rich Text". It is bound to a memo field in a table. How do I change the text or highlight color of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.