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

  • sdflksdfsda sdfklsdf sdk ksdfk s

    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).


  • xxpor

    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.
  • cleith

    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


  • Obsolete

    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
  • Dattan

    Set the TabStop property to fasle;



  • china_chinese

    TabStop=false


  • MachAngle

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

  • Steven Yetter

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

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


  • arb70sok

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

  • Visual C# Novice

    Why not use a Label instead then
  • DagAnderson

    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


  • kevin888

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


  • jaortizgonzalez

    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.
  • textbox test always highlighted on window open