Focus

  • Thread starter Thread starter Richard Grene
  • Start date Start date
R

Richard Grene

I set focus to a text box the data in the text box is highlited. When I
enter into the text box, whatever was there is replaced by what I entered.
How can I set this up so what I enter is appended to the text that is there.
I need to do this one character at a time. I'm using the KeyUp event to get
each new char entered.

Thanks,
Richard
 
Hi Richard,

I use this for that
TextBox1.SelectionStart = TextBox1.Text.Length

I hope it helps for you?

Cor
 
* "Richard Grene said:
I set focus to a text box the data in the text box is highlited. When I
enter into the text box, whatever was there is replaced by what I entered.
How can I set this up so what I enter is appended to the text that is there.
I need to do this one character at a time. I'm using the KeyUp event to get
each new char entered.

Add a handler to the textbox's 'GotFocus' event and enter this code:

\\\
Dim t As TextBox = DirectCast(sender, TextBox)
t.Select(t.TextLength, 0)
///
 
* "Cor Ligthert said:
Does my simple code not works?

It works, but you didn't say where to place it. AFAIU the OP's post, he
wants the behavior when the control gets focus and the user types in
some text.
 
Hi Herfried,
It works, but you didn't say where to place it. AFAIU the OP's post, he
wants the behavior when the control gets focus and the user types in
some text.

Will I copy this and place a message when you only send a link?

Although you did not read the message of the OP, because he stated for sure
I need to do this one character at a time. I'm using the KeyUp event to get
each new char entered.

For which what I sand works perfectly.

I find it a very awful procedure you did send. You said you have to add an
extra handler for the getFocus event as something extra (which will by the
way never fired)

I do not understand how that would work however maybe you can explain that.

Cor
 
* "Cor Ligthert said:
Will I copy this and place a message when you only send a link?

Although you did not read the message of the OP, because he stated for sure


For which what I sand works perfectly.

I find it a very awful procedure you did send. You said you have to add an
extra handler for the getFocus event as something extra (which will by the
way never fired)

I do not understand how that would work however maybe you can explain that.

When the control gets focus, the cursor is set after the last character
and not the whole text of the textbox is selected (which is the default
behavior). So tabbing to the textbox and pressing a key will /append/
it instead of /replacing/ the whole text in the textbox.
 
Hi Herfried,
that.

When the control gets focus, the cursor is set after the last character
and not the whole text of the textbox is selected (which is the default
behavior). So tabbing to the textbox and pressing a key will /append/
it instead of /replacing/ the whole text in the textbox.
In my opinion exactly as the OP was asking for. However I can be wrong.

Cor
 
Back
Top