c# - How do I highlight the text in a textbox at the startup of a window? -
c# - How do I highlight the text in a textbox at the startup of a window? -
i asked question similar few days ago here. reply works fine, exception of performing same operation @ start of window. means need have text in textbox highlighted every time window opened.
currently setting focus textbox @ startup no problem in constructor. beingness said, guessing right area perform operation in constructor. trying no luck:
public adddestination() { initializecomponent(); //give cursor focus textbox destination_textbox.focus(); //highlights text **does not work destination_textbox.selectionstart = 0; destination_textbox.selectionlength = destination_textbox.text.length; } how can create text within textbox highlighted whenever window opens?
instead of constructor, move adddestination_load event.
public adddestination() { initializecomponent(); } private void adddestination_load(object sender, eventargs e) { //give cursor focus textbox textbox1.focus(); //highlights text **does not work textbox1.selectionstart = 0; textbox1.selectionlength = textbox1.text.length; } c# wpf textbox
Comments
Post a Comment