Select text in TextBox when Form loads
-
How do I have a form appear with the text in a TextBox selected? I have a simple dialog window that has a single textbox for user input and two buttons (OK and Cancel). When the dialog window loads, I would like the text in the TextBox to be selected so that the user can start typing as soon as the window comes up, instead of having to manually click on (or tab to) the textbox. I have tried placing the following line:
textbox_sleep_time_ms->Select(0, textbox_sleep_time_ms->Text->Length);
both as the last statement in the constructor for the form, and as the only statement in the form's Load event handler, but neither one will select the text. I don't know if it's relevant, but I have set the default button for the form to the OK button so that the user can just press Enter to accept the value. -- Marcus Kwok -
How do I have a form appear with the text in a TextBox selected? I have a simple dialog window that has a single textbox for user input and two buttons (OK and Cancel). When the dialog window loads, I would like the text in the TextBox to be selected so that the user can start typing as soon as the window comes up, instead of having to manually click on (or tab to) the textbox. I have tried placing the following line:
textbox_sleep_time_ms->Select(0, textbox_sleep_time_ms->Text->Length);
both as the last statement in the constructor for the form, and as the only statement in the form's Load event handler, but neither one will select the text. I don't know if it's relevant, but I have set the default button for the form to the OK button so that the user can just press Enter to accept the value. -- Marcus Kwok