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

wow, is it me? cant select text in c# textbox

private void button1_Click(object sender, EventArgs e)
{
textBox1.SelectionStart = 0;
textBox1.SelectionLength = textBox1.Text.Length;
}
yet when the button is clicked and there is text in the textbox.... NOTHING.
what am i missing here?
Jul 12 '07 #1
3 5759

"S Moran" <s@moran.comwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
private void button1_Click(object sender, EventArgs e)
{
textBox1.SelectionStart = 0;
textBox1.SelectionLength = textBox1.Text.Length;
}
yet when the button is clicked and there is text in the textbox....
NOTHING.
what am i missing here?

In your method, try this instead:

textBox1.Focus();
textBox1.SelectAll();

Jul 12 '07 #2
yup. much nicer (and i apparently had to change the hideSelection property
to false on the textbox)
how can i unselect when the textbox loses focus?

"PvdG42" <pv**@toadstool.eduwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>
"S Moran" <s@moran.comwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
>private void button1_Click(object sender, EventArgs e)
{
textBox1.SelectionStart = 0;
textBox1.SelectionLength = textBox1.Text.Length;
}
yet when the button is clicked and there is text in the textbox....
NOTHING.
what am i missing here?


In your method, try this instead:

textBox1.Focus();
textBox1.SelectAll();
Jul 12 '07 #3

"S Moran" <s@moran.comwrote in message
news:OB****************@TK2MSFTNGP03.phx.gbl...
yup. much nicer (and i apparently had to change the hideSelection property
to false on the textbox)
how can i unselect when the textbox loses focus?

Try putting a second TextBox on your form, then a second button. In the
Click event procedure for the new button, set focus to the second TextBox.
You'll see that the text in the first TextBox is automatically deselected
when it loses focus.

Jul 12 '07 #4

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

Similar topics

3
by: Me | last post by:
Hi Folks I keep recieving the following error message when i try to bind a combobox to the value that is in a textbox. the application crashes on the following line... Me.CBoxTitle.SelectedItem...
1
by: Mad Scientist Jr | last post by:
I'm stuck trying to work with a HTML <SELECT> control and javascript (similar to DualList but that control doesn't offer enough options to totally control the text on the buttons and control, also...
3
by: Chumley the Walrus | last post by:
I have a textbox control that represents a username in a password scheme, and I'm trying to turn the ID of the textbox control (the id = lgname ) into a session object. Doing lgname.text =...
5
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a cancel and a accept button. This form is used to...
3
by: abc my vclass | last post by:
My win-form have many numericupdown controls to applied. But numericupdown control don't like textbox, text box control can automatic selected text when got focus. Is there any method can let me...
4
by: Dabbler | last post by:
Is there a way to mark the text in a TextBox control as selected so when the user types a new value the existing text is replaced? Thanks
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
1
by: geeteshss | last post by:
unable to view data in datagrid -------------------------------------------------------------------------------- the present problem is that i am unable to display data in datagrid....... but...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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...

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.