Is there a way to add a new column to a grid between 2 other columns in runtime?
Asked
Active
Viewed 182 times
-3
-
Have a look http://stackoverflow.com/questions/704724/programatically-add-column-rows-to-wpf-datagrid , http://msdn.microsoft.com/en-us/library/bb514525(v=vs.90).aspx and http://www.paulstovell.com/dynamic-datagrid – NoWar Mar 21 '13 at 19:13
-
@Peretz that does not answer the question. Not in the designer but in runtime – David Col Mar 21 '13 at 20:17
1 Answers
2
Yes, you can just do:
var index = 1; //column index to insert
var colDef = new ColumnDefinition() { Width=new GridLength(200) };
MyGrid.ColumnDefinitions.Insert(index, colDef);

Brent Stewart
- 1,830
- 14
- 21