回答
使用SelectedValu combobox1的eChanged事件來檢查選定的值。基於此禁用或啓用combobox2。
private void combobox1_SelectedValueChanged(object sender, Eventargs e)
{
if (combobox1.SelectedValue == myDisableValue)
combobox2.Enabled = false;
else
combobox2.Enabled = true;
}
您可以處理兩者的組合框的SelectedValueChanged事件,如果任何組合都有你所需值禁用另一個
因此,如果(combobox1 ==「xxx」)comboBox2被鎖定? –
或者你會推薦使用單選按鈕? –
if(combobox1.SelectedValue ==「xxx」){comboBox2.Enabled = false;} –
與此類似的東西,只設置任何你想要的屬性,或不清除它,或任何其他。 (測試組合未被數據綁定)
public partial class Form1 : Form
{
bool fireEvents = true;
public Form1()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (fireEvents) doCheck(sender, e);
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if (fireEvents) doCheck(sender, e);
}
private void doCheck(object sender, EventArgs e)
{
fireEvents = false; // because we don't have a way to cancel event bubbling
if (sender == comboBox1)
{
comboBox2.SelectedIndex = -1;
}
else if (sender == comboBox2)
{
comboBox1.SelectedIndex = -1;
}
fireEvents = true;
}
}
- 1. 篩選組合框其他組合框
- 2. java swing組合框選擇和鏈接到其他組合框
- 3. 從其他組合框的選定項目填充組合框
- 4. C#根據其他組合框添加項目到組合框
- 5. 如何從其他用戶控制禁用組合框
- 6. 如何根據另一個組合框中的選擇禁用組合框?
- 7. 如何禁用多個組合框JQuery中選擇的組合框值?
- 8. Django的 - 如何讓其他組合框
- 9. 如何在LWUIT中禁用組合框?
- 10. 當單選按鈕被選中時,組合框未被禁用
- 11. 一個組合框依賴於WPF中的其他組合框
- 12. 如何在複選框被選中時組合兩個數組
- 13. 如何動態地改變其他組合框的值改變組合框
- 14. 如何禁用組合框的輸入?
- 15. 如何從組合框禁用optgroup
- 16. 如何禁用組合框項目?
- 17. 如何禁用灰色的組合框?
- 18. 如果在combox1中選擇了一個值,那麼它應該在所有其他組合框中被禁用
- 19. 基於其他組合框的一個組合框的值 - php
- 20. 基於第一個組合框過濾其他組合框
- 21. 根據組合框的選擇,我如何從組合框excel 2010中選擇轉到其他工作表?
- 22. 如果在jComBox1中選擇的項目,那麼它應該被禁用所有其他組合框
- 23. 如何在c中使用組合框#
- 24. 如何禁用一組複選框,如果沒有選擇其他組的複選框
- 25. 如何更改組合框中的值,取決於vb.net中其他組合框中的選定項目
- 26. 組合框禁用C#啓用與js
- 27. c#wpf組合框選擇
- 28. C#組合框選擇
- 29. C# - 組合框選定值
- 30. 禁用的組合框
謝謝我使用了這個,但我想我要添加單選按鈕並使用private void radioButton1_CheckedChanged(object sender,EventArgs e) { comboBox4.Enabled = true; comboBox5.Enabled = false; } –