如何使用C#在XCeed DataGridControlWPF中添加ComboBox列

问题描述

我目前正在开发管理系统,我首先使用WPF的Microsoft默认数据网格,但是,由于它既没有分组功能,又没有过滤系统,因此我使用Xceed datagrid对其进行了更改。

问题是我找不到使用c#添加组合框列的任何方法。我尝试了一切,但没有任何效果。这是我的最后尝试:

for (int i = 0; i < this.DGV.Columns.Count; i++)
{
    var Column = this.DGV.Columns[i];

    if (Column.FieldName == "BranchGroupId")
    {
        System.Windows.FrameworkElementFactory comboBox = new System.Windows.FrameworkElementFactory(typeof(ComboBox));

        comboBox.SetValue(ComboBox.ItemsSourceProperty,((ViewModel.BranchViewModel)this.DataContext).BranchesGroup_Collection);
                                          
        comboBox.SetValue(ComboBox.DisplayMemberPathProperty,"Name");
                                          
        comboBox.SetValue(ComboBox.SelectedValuePathProperty,"Id");
                      
        this.DGV.Columns[i].CellEditor = new Xceed.Wpf.DataGrid.CellEditor();
        this.DGV.Columns[i].CellEditor.EditTemplate = new System.Windows.DataTemplate();
        this.DGV.Columns[i].CellEditor.EditTemplate.VisualTree = comboBox;
    }
}

请帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...