Silverlight DataGrid - 在运行时添加列

时间:2022-12-15 13:21:33

I would like to be able to add / remove columns to my datagrid, based on UI inputs from the user.

我希望能够根据用户的UI输入向我的数据网格添加/删除列。

Is this possible? Any good articles on this?

这可能吗?关于这个的任何好文章?

Thanks, Mark

1 个解决方案

#1


Yes it is possible:

对的,这是可能的:

// Candidates is the DataGrid

var newColumn = new DataGridTextColumn() { Header="New Column"};
Candidates.Columns.Add(newColumn);
Candidates.Columns.Remove(newColumn);

#1


Yes it is possible:

对的,这是可能的:

// Candidates is the DataGrid

var newColumn = new DataGridTextColumn() { Header="New Column"};
Candidates.Columns.Add(newColumn);
Candidates.Columns.Remove(newColumn);