Focus at the right spot

A

Arne Garvander

I use
Mytextbox.text = "Default"
mytextbox.focus

How do I focus on the first character in the text box?
 
B

BlackWasp

You need to change the selection within the textbox. This is done with the
SelectionStart and SelectionLength properties. The start is the start
position for selection, the length is the number of characters to be
selected from that point or zero for no selection, just your flashing
cursor. For example, the following code moves the cursor to just after the
fifth character in the textbox.

textBox1.SelectionStart = 5;
textBox1.SelectionLength = 0;
 
H

Herfried K. Wagner [MVP]

BlackWasp said:
You need to change the selection within the textbox. This is done with
the SelectionStart and SelectionLength properties.

.... or via the control's parameterized 'Select' method.
 

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

Similar Threads


Top