6 个解决方案
#1
int t = 0;
private void comboBox1_DropDown(object sender, EventArgs e)
{
t = this.comboBox1.SelectedIndex;
}
private void comboBox1_DropDownClosed(object sender, EventArgs e)
{
if (MessageBox.Show("yse or no", "", MessageBoxButtons.YesNo) == DialogResult.No)
this.comboBox1.SelectedIndex = t;
}
#2
private int comboindex=-1;
private void comboBox1_DropDown(object sender, System.EventArgs e)
{
comboindex=comboBox1.SelectedIndex;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(comboBox1.SelectedIndex==comboindex)return;
if(MessageBox.Show("是否确定","提示",MessageBoxButtons.OKCancel)!=DialogResult.OK)
{
comboBox1.SelectedIndex=comboindex;
}
}
#3
两楼都可以.
#4
一样的代码
#5
上面1楼和2楼的都行,原理都是先把之前那个索引存起来,然后再根据判断选择是否需要确认,如果退回则把以前存的那个索引再次赋值过去。
#6
结帐,后来我也是这么做的。谢谢大家
#1
int t = 0;
private void comboBox1_DropDown(object sender, EventArgs e)
{
t = this.comboBox1.SelectedIndex;
}
private void comboBox1_DropDownClosed(object sender, EventArgs e)
{
if (MessageBox.Show("yse or no", "", MessageBoxButtons.YesNo) == DialogResult.No)
this.comboBox1.SelectedIndex = t;
}
#2
private int comboindex=-1;
private void comboBox1_DropDown(object sender, System.EventArgs e)
{
comboindex=comboBox1.SelectedIndex;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(comboBox1.SelectedIndex==comboindex)return;
if(MessageBox.Show("是否确定","提示",MessageBoxButtons.OKCancel)!=DialogResult.OK)
{
comboBox1.SelectedIndex=comboindex;
}
}
#3
两楼都可以.
#4
一样的代码
#5
上面1楼和2楼的都行,原理都是先把之前那个索引存起来,然后再根据判断选择是否需要确认,如果退回则把以前存的那个索引再次赋值过去。
#6
结帐,后来我也是这么做的。谢谢大家