SELECT method for a textbox control: broken or by design?

  • Thread starter Cindy M -WordMVP-
  • Start date
C

Cindy M -WordMVP-

Hi all

While working my way through a VB.NET exercise, I came
across something that didn't do what the text said it
should and I'm wondering if it's supposed to behave this
way, or not.

txtNote.Text = AllText
txtNote.Enabled = True
'txtNote.Select()
txtNote.Select(0, 0) 'deselect text

txtNote is a textbox control on a windows form. Alltext is
a string variable. As the code stands, the txtNote control
is NOT selected, focus remains in the control that had the
selection when the code is executed.

If I include the line that's currently commented out, first
selecting the control specifically, then setting the
selection length (doesn't matter what numbers I put in the
function), it works as I'd expect, and focus is in the text
box.

Should it always be necessary to use Select twice, or am I
missing something?

-- Cindy
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top