Highlighted
Absent Member.
Absent Member.
2796 views

Textbox value Highlighted on Tab

Is there a way to turn off the selection of the value in a textbox field when you tab to the field?

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Textbox value Highlighted on Tab

You can set the SelectionStart property of the textbox to 0 in the form load event or after setting the Text property.

       method-id Form1_Load final private.
       procedure division using by value sender as object e as type System.EventArgs.
      
           set textBox1::SelectionStart to 0
           set textBox2::SelectionStart to 0
           set textBox3::SelectionStart to 0
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Textbox value Highlighted on Tab

Thanks

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Textbox value Highlighted on Tab

That did not seem to do anything.  I put it into the code when I init the form and it still selects the full field when you tab to the textbox.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Textbox value Highlighted on Tab

Here the other thing I found.  If you hit the end or home key and remove the selection of text, if you tab back to the field the text is not selected the next time.  Only on the initial tab to the field.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Textbox value Highlighted on Tab

This is standard behavior of the textbox field. The text selection occurs when you tab into the field the first time but not if you click into the field, etc.

Try the following code:

          set textBox1::SelectionStart to 0
          set textBox2::SelectionStart to 0
          set textBox3::SelectionStart to 0
          invoke textBox1::DeselectAll
          invoke textBox2::DeselectAll
          invoke textBox3::DeselectAll

The easiest way to change the behavior of the textbox all together would be to create your own version of textbox by inheriting from it and then overriding the desired behavior.

There is a good article I found here:

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Textbox value Highlighted on Tab

Thanks

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.