开发者

Set the cursor on a textbox after selecting an item in a ListBox

开发者 https://www.devze.com 2023-01-05 23:19 出处:网络
When I select an item开发者_如何学Go on my Listbox, a Textbox is filled with the selected text for editing. How can I get the cursor to focus on the Textbox text so I don\'t have to click on it with m

When I select an item开发者_如何学Go on my Listbox, a Textbox is filled with the selected text for editing. How can I get the cursor to focus on the Textbox text so I don't have to click on it with my mouse before editing?


Just use the Control's Focus method:

TextBox1.Text = selectedItemText;    
TextBox1.Focus();

Or

TextBox1.Select();

Or if you just want to put a cursor after the last letter in the TextBox:

TextBox1.Select(TextBox1.Text.Length, 0);
TextBox1.Focus();
0

精彩评论

暂无评论...
验证码 换一张
取 消