Drag and drop between ultragrids in different classes but in

Posted by MBeynon on 10-Apr-2013 06:25

HI,

I have a form which is divided into cells by the .NET tablelayout component. Each one of these cells contains a ABL user control class which has a number of grids within it.

I'd like to be able to drag and drop rows beween grids in different 'cells'. I'm using the standard drag and drop grid code but my reference to my grid that is being dragged is

lost when I go to 'drop' the row onto the different cell.

Each Class that is attached to a cell and contains the grids has it's own drag and drop code. I've highlighted the grid object reference that is being lost:

  METHOD PRIVATE VOID ultraGrid_DragDrop(INPUT sender AS System.Object,
                                         INPUT e AS System.Windows.Forms.DragEventArgs ):
   
    DEFINE VARIABLE oSelRows  AS Infragistics.Win.UltraWinGrid.SelectedRowsCollection NO-UNDO.
    DEFINE VARIABLE hSrcQuery AS HANDLE                                               NO-UNDO.
    DEFINE VARIABLE hTgtQuery AS HANDLE                                               NO-UNDO.
   

    /* Get the handle of the source query from the bindingSource that feeds the Source grid */
    hSrcQuery = CAST(ultraGridDrag:DataSource,Progress.Data.BindingSource):handle.
   
    /* Get the handle of the target query from the bindingSource that feeds the current grid */
    hTgtQuery = CAST(CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid):DataSource,Progress.Data.BindingSource):handle.

    oSelRows = CAST(CAST(e:Data,System.Windows.Forms.IDataObject):GetData(Progress.Util.TypeHelper:GetType('Infragistics.Win.UltraWinGrid.SelectedRowsCollection')),
      Infragistics.Win.UltraWinGrid.SelectedRowsCollection).

    MoveRows(INPUT hSrcQuery,
             INPUT hTgtQuery,
             INPUT oSelRows,
             INPUT CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid)).
  END METHOD.

  METHOD PRIVATE VOID ultraGrid_DragOver( INPUT sender AS System.Object,
                                          INPUT e      AS System.Windows.Forms.DragEventArgs ):
   
    DEFINE VARIABLE oGrid              AS Infragistics.Win.UltraWinGrid.UltraGrid NO-UNDO.
    DEFINE VARIABLE oPointInGridCoords AS System.Drawing.Point                    NO-UNDO.
   
    ASSIGN
      e:Effect           = System.Windows.Forms.DragDropEffects:Move
      oGrid              = CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid)
      oPointInGridCoords = oGrid:PointToClient(NEW System.Drawing.Point(e:X,e:Y)).

    IF oPointInGridCoords:Y LT 5 THEN /* Scroll up.*/
      oGrid:ActiveRowScrollRegion:Scroll(Infragistics.Win.UltraWinGrid.RowScrollAction:LineUp).
    ELSE IF oPointInGridCoords:Y GT oGrid:Height - 5 THEN /* Scroll down.*/
        oGrid:ActiveRowScrollRegion:Scroll(Infragistics.Win.UltraWinGrid.RowScrollAction:LineDown).
       
  END METHOD.

  METHOD PRIVATE VOID ultraGrid_SelectionDrag( INPUT sender AS System.Object,INPUT e AS System.ComponentModel.CancelEventArgs ):
   
    ASSIGN
      ultraGridDrag = NEW Infragistics.Win.UltraWinGrid.UltraGrid()
      ultraGridDrag = CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid)
.
   
    CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid):DoDragDrop(CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid):Selected:Rows, System.Windows.Forms.DragDropEffects:Move).

  END METHOD.

This approach work when I don't use a class to hold the grids but just populalate each cell of the table in the main form itself.

Is there any way around this as I'd like to keep the code modular and self contained?

Mark.

All Replies

Posted by jquerijero on 08-May-2013 10:40

The drag and drop code seems to be for dragging and dropping in the same usercontrol. The other instances of your usercontrols doesn't see ultraGridBag.

Normally;

SelectionDrag/DragStart (Source) - Setup data for the drag operation. I prefer simple text.

DragOver (Destination) - Checks if the drag operation data is valid and diplays the necessary cursor (no drop, and etc.).

DragDrop (Destination) - Reassembles the drag operation data

Aslo you don't need the extra NEW if you are assigning;

ultraGridDrag = NEW Infragistics.Win.UltraWinGrid.UltraGrid()

ultraGridDrag = CAST(sender,Infragistics.Win.UltraWinGrid.UltraGrid).

This thread is closed