删除文本框里面被选中的文本 纠错
namespace 12{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Cut();
}
}
}
这样对吗? 如果不对正确的怎么写???
if (textBox1.SelectedText != "") textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart) +textBox1.Text.Substring(textBox1.SelectionLength +textBox1.SelectionStart);
if (textBox1.SelectedText != "") textBox1.Text = textBox1.Text.Replace(textBox1.SelectedText, "");这个方法更简单一点