textbox test always highlighted on window open

I have a help non-modal dialog that just displays a text message in a textbox. The textbox is the only component in the form.

The problem is that when the dialog is displayed, all the text in the textbox is selected / highlighted. I have tried calling deselectAll on the textbox in the constructor and in the load and visible changed methods with no change.

How do I get rid of the selection



Answer this question

textbox test always highlighted on window open

  • Demonite

    don't set the focus on the textbox when the form loads


  • Luuk

    You could try this:
    tbx_Search.Select(_tbx_Search.Text.Length,0);

  • GeeeTeee

    I am not doing it myself. How do I prevent focus from going to the textbox if it is the only component in the form


  • MaryLuke

    Set the TabStop property to fasle;



  • Sonic1981

    Why not use a Label instead then
  • Uri S.

    The only problem with the above is that I would prefer to have word-wrap available so that a horizontal scrollbar is not required.


  • Chris_Botha

    Because a label does not deal well with multi-line strings or scrollbars.
  • Sashah

    That worked. Could I also ask how to prevent the carat from being displayed in the textbox Is there a way to prevent the textbox from being focusable
  • vidashgan

    Even if you set ReadOnly to true for a TextBox the content can still be selected, and if I understand the OP right he doesn't want to allow that.
  • abc23

    If you still want to use a textbox, you can set its "readonly" property to True.

  • Hugocpp

    Correct. I don't mind selectable / highlightable, I just don't want the carat to show up. Having a blinking carat in the textbox makes it seem like it is editable (which it is not because I have set readonly to true).

    What I want is a read-only multi-line text display area. It should not require a horizontal scrollbar (ie. word-wrap). It should not display the carat (I would have though read-only would have taken care of this but it does not).


  • c# crack

    That prevents the user from being able to put focus on the component by hitting tab, however it does not prevent the user from being able to put the focus on the component by clicking it.

    I don't want the I-beam carot ever displayed in the textbox.

    Any thoughts


  • Greg Smolyn

    If you use a Label with AutoSize set to true and set the AutoScroll property of its parent control to true it should handle multiline strings just fine and you'll get scrollbars if the content exceeds the size of the parent control.
  • George S.

    TabStop=false


  • textbox test always highlighted on window open