.net - 根据另一个组合框的选定值填充一个组合框

标签 .net wpf combobox

我有多个组合框(具体来说:3),每个组合框的值取决于前一个组合框的选定值。关于如何在 WPF 中实现这一点的任何建议?

每个组合框都有 list<> 作为其项目源。

最佳答案

让我们假设您的组合框的名称是 comboBox1 , comboBox2comboBox3下面我只举一个事件的例子。在此基础上,您可以为所有组合框触发事件。

comboBox1.SelectionChanged += new SelectionChangedEventHandler(comboBox1_SelectionChanged);

这是事件调用
void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    comboBox2.SelectedIndex = comboBox1.SelectedIndex;
//do other work here
}

关于.net - 根据另一个组合框的选定值填充一个组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10990854/

相关文章:

c# - WPF:组合框的下拉列表突出显示了文本

java - 如何在使用 GlanedList..evenlist 时更新组合框

C# 交互位置

c# - WPF TextBox 事件 TextChanged PreviewTextInput 不触发

c# - 使用 .Net 在网络机器上停止进程

c# - 正确调整 wpf ListView 最后一列的大小

.net - PeakWorkingSet64,没有给我正确的结果

wpf - [Multi]DataTrigger "OR"语句?

c# - 如何在 XAML 中创建 "Window"菜单?

excel - 使用 Excel VBA 中的行值填充组合框