【问题标题】:fill individual combobox in gridview combocolumn from another event从另一个事件填充gridview组合列中的单个组合框
【发布时间】:2013-04-22 06:17:42
【问题描述】:

我在 gridview 中创建了两个 Combobox 列。现在我想根据第一个组合框的值填充第二个组合框(在第一个组合框 selectedValueChanged 事件上)。请回复。

【问题讨论】:

  • 欢迎来到 Stackoverflow。到目前为止,您尝试过什么吗?请先展示你的努力..阅读FAQHow to Ask也..

标签: c# gridview window


【解决方案1】:

一般方法可能如下所示:

private MyType1 _selectedItem1;
public MyType1 SelectedItem1
{
    get { return _selectedItem1; }
    set 
    {
        if (_selectedItem1 == value) return;
        _selectedItem1 = value;
        //replace with string implementation, if needed
        OnPropertyChanged(() => SelectedItem1);
        if (_selectedItem1 == ...)
        {
            ItemsSource2 = new List<MyClass2> { ... };
        }
        else if (_selectedItem1 == ...)
        {
            ...
        }
    }
}

private IList<MyType2> _itemsSource2;
public IList<MyType2> ItemsSource2
{
    get { return _itemsSource2; }
    set 
    {
        if (_itemsSource2 == value) return;
        _itemsSource2 = value;
        OnPropertyChanged(() => ItemsSource2);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多