本文介绍了如何选择文本框中的所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Hello All i有windows App 一些文本框 i tab in textbox by this codeHello Alli have windows Appsome text boxsi tab between textbox by this codeprivate void AstTxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { AltTxt.Focus(); } } 但我想要什么时候去下一个文本框 选择此文本框中的数据而不删除它but i want when go next text box select data in this textbox not delete it推荐答案您好, 尝试以下操作:Hello,try the following:private void AstTxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { AltTxt.Focus(); AltTxt.SelectionStart = 0; AltTxt.SelectionLength = AltText.Text.Length; } } TextBox,在焦点 [ ^ ]事件不会删除其中的文本。它只是将焦点从其他控件改为此。 其次,要在TextBox中选择整个文本,可以使用Selection(选择开始 [ ^ ]和 SelectionLength [ ^ ])属性,用于输入要在当前选择中选择的字符;在MSDN链接上阅读更多内容。由于你想要选择所有这些,试试这个,TextBox, under Focus[^] event doesn't delete the text inside it. It just changes the focus from other controls, to this one.Secondly, to select entire text inside the TextBox, you can use the Selection (SelectionStart[^] and SelectionLength[^]) properties, to enter the characters that you want to select in the current selection; read more on MSDN links. Since you want to select all of them, try this,// Set the focusAltText.Focus();// Since beginning; zeroth characterAltTxt.SelectionStart = 0;// Upto the last character.AtlTxt.SelectionLength = textbox.Text.Length; 以上代码会在您进入内部时从控件中选择文本。没有代码可以删除它,因此它不会从TextBox中删除任何内容。Above code would select the text from the control when you're inside it. There is no code to delete it, so it won't delete anything from the TextBox. 这篇关于如何选择文本框中的所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 05:47