Infragistics-UltraGrid+UltraComboEditor实现下拉列表多选

1.首先添加UltraGrid控件和UltraComboEditor控件

2.设定两个控件的样式

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            ultraGrid1.DisplayLayout.Bands[0].Columns["UserName"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;

            ultraComboEditor1.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft;
            ultraComboEditor1.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox;
            ultraComboEditor1.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems;
            ultraComboEditor1.CheckedListSettings.ListSeparator = ",";
            ultraComboEditor1.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item;
            ultraGrid1.DisplayLayout.Bands[0].Columns["UserName"].EditorComponent = ultraComboEditor1;
        }

ultraGrid1.DisplayLayout.Bands[0].Columns["UserName"].EditorComponent = ultraComboEditor1;是将UltraComboEditor绑定到列上。

3.最后将数据源绑定

List list = new List();
        List username = new List();

 ultraComboEditor1.DataSource = username;
            ultraGrid1.DataSource = list;

你可能感兴趣的:(C#,UltraGrid,多选下拉列表)