Skip to main content

Have I tab to a text file on a windows form, the full text in the field is selected and highlighted,  Is there a way to not have that happen when tabbing to a text field?

Have I tab to a text file on a windows form, the full text in the field is selected and highlighted,  Is there a way to not have that happen when tabbing to a text field?

Highlighting the text when tabbing into the TextBox control the first time is the default behavior

The easiest way to turn this poff is to set the SelectionStart property to 0 after setting the Text property programmatically.

   set textBox1::SelectionStart to 0

You might want to take a look at the article here for an example of how to subclass the TextBox control to create anew version with the desired behavior.


Have I tab to a text file on a windows form, the full text in the field is selected and highlighted,  Is there a way to not have that happen when tabbing to a text field?

The SelectionStart did not work.  I inserted it in the design, is that the correct place?


Have I tab to a text file on a windows form, the full text in the field is selected and highlighted,  Is there a way to not have that happen when tabbing to a text field?

I am not sure what you mean by inserted it in the design. I do not show that SelectionStart is a valid property that can be set within the Windows Forms designer.

I was setting it in the new method directly after the InitializeComponent was invoked

method-id NEW.

      procedure division.

          invoke self::InitializeComponent

          set textBox1::Text to "ABC"

          set textBox1::SelectionStart to 0

          set textBox2::Text to "12345"

          set textBox2::SelectionStart to 0

          goback.

      end method.