Hello,
I am trying to write a User Control which acts as a "column selector" for a RadGridView control.
My "ColumnSelector" control recieves a RadGridView control, and displays a list of the grid view's columns using a RadTreeView control. Next to the list I have two buttons, Up & Down, which allow the user to change the column order of the gridview.
The RadTreeView in the "ColumnSelector" control is binded to the RadGridView's Columns property, so that each change the user makes affects on the treeview the actual gridview.
In the up/down buttons event handler I need to reorder the columns, move the selected column one spot up or down.
I've tried using the GridView's ReorderColumns(old index, new index) method but it doesn't do anything. If someone could explain to me how to get it to work that'd be great.
Since ReorderColumns didn't work, I tried to make the swap myself:
This causes an extra "blank" column to appear in the grid, between the real columns.
Has anyone ever seen this behavior? why is it happening?
Is there an example somewhere of how to implement such a "column selector" control? maybe my approach about the whole thing is incorrect..
This is how my treeview XAML looks like:
The ColumnsCoverter used converts between a GridViewColumnCollection (the type of RadGridView.Columns) and ObservableCollection<RadTreeViewItem>
Thanks,
Lior
I am trying to write a User Control which acts as a "column selector" for a RadGridView control.
My "ColumnSelector" control recieves a RadGridView control, and displays a list of the grid view's columns using a RadTreeView control. Next to the list I have two buttons, Up & Down, which allow the user to change the column order of the gridview.
The RadTreeView in the "ColumnSelector" control is binded to the RadGridView's Columns property, so that each change the user makes affects on the treeview the actual gridview.
In the up/down buttons event handler I need to reorder the columns, move the selected column one spot up or down.
I've tried using the GridView's ReorderColumns(old index, new index) method but it doesn't do anything. If someone could explain to me how to get it to work that'd be great.
Since ReorderColumns didn't work, I tried to make the swap myself:
//get the selected column
GridViewColumn column1 = Grid.Columns[selectedIndex];
//remove the column at the original position
Grid.Columns.RemoveAt(selectedIndex);
//add the column at the new position
Grid.Columns.Insert(selectedIndex + 1, column1);
This causes an extra "blank" column to appear in the grid, between the real columns.
Has anyone ever seen this behavior? why is it happening?
Is there an example somewhere of how to implement such a "column selector" control? maybe my approach about the whole thing is incorrect..
This is how my treeview XAML looks like:
<
nice:NiceTreeView
ItemsSource
=
"{Binding Columns, Converter={StaticResource columnsConverter}, Mode=TwoWay}"
IsEditable
=
"True"
MinWidth
=
"200"
MaxHeight
=
"380"
x:Name
=
"itemsControl"
IsDragPreviewEnabled
=
"False"
IsDragTooltipEnabled
=
"False"
IsDropPreviewLineEnabled
=
"False"
IsOptionElementsEnabled
=
"True"
IsDragDropEnabled
=
"True"
ItemsOptionListType
=
"CheckList"
Checked
=
"itemsControl_Checked"
Unchecked
=
"itemsControl_UnChecked"
ItemDoubleClick
=
"itemsControl_ItemDoubleClick"
Edited
=
"itemsControl_Edited"
ItemEditTemplate
=
"{StaticResource editTemplate}"
>
</
nice:NiceTreeView
>
The ColumnsCoverter used converts between a GridViewColumnCollection (the type of RadGridView.Columns) and ObservableCollection<RadTreeViewItem>
Thanks,
Lior