为什么点击Button不能高亮文本框中的文本?
以下内容为程序代码:
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "012345";
textBox2.Select(1, 2); // 这里为什么不能高亮textBox2中的12(蓝色背景,白色字)
}
以下内容为程序代码:
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "012345";
textBox2.Select(1, 2); // 这里为什么不能高亮textBox2中的12(蓝色背景,白色字)
}
{
textBox2.Text = "012345";
textBox2.Focus();
textBox2.Select(1, 2); // 这里为什么不能高亮textBox2中的12(蓝色背景,白色字)
}
private void button2_Click(object sender, System.EventArgs e)
{
textBox1.Text = "012345";
textBox1.Select(0,2);
} private void button3_Click(object sender, System.EventArgs e)
{
textBox1.Text = textBox1.SelectedText;
}
来显示值
先textBox2.Focux()后可以,但在TreeView的AfterSelect后为什么不同,也是同样的代码啊?public class MyTag
{
public int Index;
public int Length; public MyTag(int index, int length)
{
Index = index;
Length = length;
}
}
}
// 在单击TreeView的node的文本时为什么不能TextBox中的文本(蓝色背景,白色字的效果),
// 而在单击node的+或-号时却可以选择TextBox中的文本?
private void MatchTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
MyTag tag = (MyTag) e.Node.Tag;
MessageBox.Show(string.Format("index = {0};\r\n\r\nlength = {1};",
tag.Index.ToString(),
tag.Length.ToString()));
SampleStringTextBox.Focus();
SampleStringTextBox.Select(tag.Index, tag.Length);
}
textBox2.Select(1, 2);
textBox2.Focus();