private void p_button1_Click(object sender, EventArgs e)
{
position = richtext.SelectionStart;
richtext.Text = richtext.Text.Insert(position, p_button1.Text);
richtext.Focus();
richtext.SelectionStart = position + p_button1.Text.Length;
}
private void p_button2_Click(object sender, EventArgs e)
{
position = richtext.SelectionStart;
richtext.Text = richtext.Text.Insert(position, p_button2.Text);
richtext.Focus();
richtext.SelectionStart = position + p_button2.Text.Length;
}
private void p_button3_Click(object sender, EventArgs e)
{
position = richtext.SelectionStart;
richtext.Text = richtext.Text.Insert(position, p_button3.Text);
richtext.Focus();
richtext.SelectionStart = position + p_button3.Text.Length;
}
这三段代码除了p_button后的数字不同外,其他都相同,请问有没办法使它简化,我有好几十个按钮,总不可能每个都写吧、、、、