cursor in textbox control

I need some help showing the cursor position in a text box on windows form.

I’m using two buttons on a windows form to move a text insertion point to the left or right in a single line text box on the same form. The text insertion point does move left and right as commanded but I get no cursor in the text box to indicate where in the text box the insertion point is located.

In VB 6 the cursor (flashing vertical bar) in the text box was shown at the txt1.SelStart location. The same does not seem to be true in VB .net when I use txt1.text.SelectionStart.

I’ve tried everything I can think of to get the text cursor to show location.

So, in VB .net how do I get the text box cursor to show up

Can anyone help ....

Cliffie



Answer this question

cursor in textbox control

  • WXU

    Thanks for the quick reply..

    Yes. the CURSOR property is set to IBeam and the usewaitcursor is set FALSE. Still not cursor at the .SelectionStart location in the text box.

    Cliffie

     


  • nalsur8

    just a suggestion...because I was unable to duplicate your problem with the textbox...

    make usre your cursor property is set to a valid system cursor and the usewaitcursor property is set to false



  • am09qx30

    Yeah, they changed that one. Admittedly, the VB6 way was pretty miserable and a never ending source of exceptions. Now it is TextBox1.Focused = True.


  • delaysteam

    Actually the “TextBox1.Focused = True” doesn’t work. The .Focused property is a read only thing. So you can’t set it true or false.

    However. In looking at that I found the related method “Txt1.Focus()” will switch the focus to the text box and I can finally see my caret/cursor.

    Thanks a lot gentleman. This discussion helped me a lot. This was my last problem to solve on this project. I can now deliver my first .net software to the customer on Monday.

    Cliffie


  • Alex Cane

    You'd probably want to see the caret, not the cursor. Just put the focus back on the textbox after you move the caret to make it visible again.



  • kubilay

    FYI....The cursor does not show in the textbox until it has focus

  • Jaxsurfer

    Ya.. You’re correct. In this case it’s called a Caret not a Cursor.

    So how do I get the focus back on the text box. I can’t click on it because the system I’m working on has a touch screen (no mouse). I have to use touch screen buttons to move the caret in the text box. In old VB6 I could get the focus on the text box by the .SetFocus method. I don’t see that in VB.net.

    I know these are dumb questions and really do appreciate the help.

    So how do I get the focus back on the text box (so I can see the caret/cursor) with no .SetFocus method on that control

    Cliffie


  • cursor in textbox control