(Infragistics 2008 Vol. 3, CLR 2.0)
Infragistics's UltraGrid
comes with a column chooser user control, which is simply a vertical arrangement of columns with checkboxes that toggle a column's hidden state. In addition, it allows you to pick a column and drag it directly to the grid so you don't have to manually position it afterwards. (This is particularly handy when you already have a lot of visible columns and have no clue where the new one ended up.)
I'm building my own column chooser based on an UltraTree
. Getting the checkboxes to behave the same wasn't an issue, but I haven't found a way to drag a column from the tree to the grid and have it accept it.
In my tree, each UltraTreeNode
has a Tag
with the following struct
:
Private Structure DraggableGridColumn
Public NodeKey As String
Public NodeName As String
Public ParentKey As String
Public Column As UltraGridColumn
End Structure
I then have an event as follows:
Private Sub columnsTree_SelectionDragStart(ByVal sender As Object, ByVal e As System.EventArgs) Handles columnsTree.SelectionDragStart
If columnsTree.SelectedNodes.Count <> 1 Then
Return
End If
If Not TypeOf columnsTree.SelectedNodes(0).Tag Is DraggableGridColumn Then
Return
End If
Dim column As UltraGridColumn = CType(columnsTree.SelectedNodes(0).Tag, DraggableGridColumn).Column
columnsTree.DoDragDrop(column, DragDropEffects.All)
End Sub
In the DoDragDrop
call, neither column
(of type UltraGridColumn
) nor column.Header
(of type ColumnHeader
) get accepted by the grid. I assume I'm sending the wrong type, and/or that the grid expects a special struct
with some additional information. Unfortunately, I've also failed to catch an event (both on the column chooser side as well as on the grid side) where Infragistics's normal column chooser does this properly; the normal drag & drop events never seem to fire.