我在我的Windows应用程序中有两个按钮。
Button1执行一个任务:
按钮2执行以下操作。
我只想用一个按钮来触发两个事件。但我希望先调用button2的事件,然后再调用button1的事件。也就是说,我想使用一个按钮替代按钮1和按钮2,并且当我点击时,首先要做的事情是将列表框中的项目获取到文本框中。
然后开始进度条事件并关闭连接 X。
Button1执行一个任务:
private void button1_Click(object sender, EventArgs e)
{
progressBar1.Value = 0;
String[] a = textBox7.Text.Split('#');
progressBar1.Maximum = a.Length;
for (var i = 0; i <= a.GetUpperBound(0); i++)
{
ansh.Close();
progressBar1.Value++;
}
}
按钮2执行以下操作。
private void button2_Click(object sender, EventArgs e)
{
foreach (string item in listBox2.Items)
textBox7.Text += item.Contains("@") ? string.Format("{0}#", item.Split('@')[0]) : string.Empty;
}
我只想用一个按钮来触发两个事件。但我希望先调用button2的事件,然后再调用button1的事件。也就是说,我想使用一个按钮替代按钮1和按钮2,并且当我点击时,首先要做的事情是将列表框中的项目获取到文本框中。
{
foreach (string item in listBox2.Items)
textBox7.Text += item.Contains("@") ? string.Format("{0}#", item.Split('@')[0]) : string.Empty;
}
然后开始进度条事件并关闭连接 X。
progressBar1.Value = 0;
String[] a = textBox7.Text.Split('#');
progressBar1.Maximum = a.Length;
for (var i = 0; i <= a.GetUpperBound(0); i++)
{
ansh.Close();
progressBar1.Value++;
}