Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
585
Mimicking the UltraGridColumnChooser's drag & drop ability
posted

(Infragistics 2008 Vol. 3, CLR 2.0)

I'm building my own column chooser based on an UltraTree to replace the UltraGridColumnChooser. 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.

Parents
  • 469350
    Offline posted

    Hi Stefan,

    It appears to me that you are starting a Drag operation in the tree and are expecting the grid to automatically recognize the data being dragged and do the rest of the drop logic for you. This will not work. The grid is not going to be able to automatically do this.

    You are going to need to handle the DropOver and DragDrop events of the grid yourself and place the column where you want it by coding it.

Reply Children
No Data