Highlighted
Absent Member.
Absent Member.
1124 views

Selected Text

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?

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Selected Text

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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Selected Text

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

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Selected Text

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.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.