如果选择其他组合框如何禁用组合框(C#) [英] How to Disable comboBox if other comboBox is selected (C#)
本文介绍了如果选择其他组合框如何禁用组合框(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
反正有禁用组合框,如果不同的组合框具有某种在它的文字或价值。我已经尝试了几件事情似乎并不能得到它的工作。
Is there anyway to disable a combobox if a different combobox has some sort of text or value in it. I have tried a couple things and can't seem to get it to work.
下面是示例
推荐答案
使用combobox1的SelectedValueChanged事件来检查所选值。禁用或启用基于该combobox2。
Use the SelectedValueChanged event of combobox1 to check for the selected values. Disable or enable combobox2 based upon that.
private void combobox1_SelectedValueChanged(object sender, Eventargs e)
{
if (combobox1.SelectedValue == myDisableValue)
combobox2.Enabled = false;
else
combobox2.Enabled = true;
}
这篇关于如果选择其他组合框如何禁用组合框(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文