GUI for .NET DragAndDrop Samples
 
Forums / SmartComponent Library - Developer Forum / GUI for .NET DragAndDrop Samples

GUI for .NET DragAndDrop Samples

4 posts, 0 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    13 Dec 2019
    Link to this post
    Does anyone have any examples of using DragAndDrop from one UltraGrid to another?
  2. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    14 Dec 2019 in reply to Roger Blanchard
    Link to this post
    I ended up using the SelectionDrag event of the grid I wanted to copy rows from and calling DoDragDrop to capture the selectedrows of the grid.

    DO ON ERROR UNDO, THROW:
      
       THIS-OBJECT:PriceBrowser:DoDragDrop(THIS-OBJECT:PriceBrowser:Selected:Rows,
                                              DragDropEffects:Copy
                                              ).
                                          
       CATCH eError AS Progress.Lang.Error:
        LogManagerWrapper:WriteError(eError).
       END CATCH. 
      
      END. 

    I then use DragDrop event on the grid I want to copy the selectedrows to process the selectedrows. I loop through the rows collection and then use the DatasetModel class to create records if necessary. This seems to work but I am thinking I should create a TT to contain the info I need to create the DB records and then send it to the server for processing using a business task. This way I only have one call to the server.

    DO ON ERROR UNDO, THROW:
       
       oSelRows = CAST(CAST(e:Data,
                               System.Windows.Forms.IDataObject):GetData(Progress.Util.TypeHelper:GetType('Infragistics.Win.UltraWinGrid.SelectedRowsCollection')),
                          Infragistics.Win.UltraWinGrid.SelectedRowsCollection
                          ).
                         
       IF NOT VALID-OBJECT (oSelRows) THEN
        RETURN.

    END.


  3. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    15 Dec 2019 in reply to Roger Blanchard
    Link to this post
    I personally prefer not to use the actual grid rows (SelectedRows collection) as the payload of the D&D operation. This would create a tight dependency between the implementation of the sender and recipient. 

    In the SmartFunctionMaintenanceForm we're using a .NET generic dictionary with a map of field names and field values.

    You can use any type that inherits from System.Object as the payload for a drag and drop operation. 

        METHOD PRIVATE VOID smartDataBrowser1_MouseDown (sender AS System.Object,
                                                         e      AS System.Windows.Forms.MouseEventArgs):

            DEFINE VARIABLE oUIElement  AS Infragistics.Win.UIElement    NO-UNDO .
            DEFINE VARIABLE oDictionary AS "Dictionary<String,String>":U NO-UNDO .

            /* Find out if the RowSelect is being clicked, don't do D&D when clicking a cell */
            oUIElement = smartDataBrowser1:DisplayLayout:UIElement:ElementFromPoint (e:Location) .

            IF TYPE-OF (oUIElement, Infragistics.Win.UltraWinGrid.RowSelectorUIElement)
               AND smartDataBrowser1:Selected:Rows:Count > 0 THEN DO:
                oDictionary = NEW "Dictionary<String,String>":U ().

                oDictionary:Add ("eSmartFunction.FunctionGuid":U, FunctionAdapter:GetFieldValues("FunctionGuid":U)).
                oDictionary:Add ("eSmartFunction.FunctionName":U, FunctionAdapter:GetFieldValues("FunctionName":U)).
                oDictionary:Add ("eSmartFunction.FunctionSmallImage":U, FunctionAdapter:GetFieldValues("FunctionSmallImage":U)).
                oDictionary:Add ("eSmartFunction.FunctionLargeImage":U, FunctionAdapter:GetFieldValues("FunctionLargeImage":U)).

                smartDataBrowser1:DoDragDrop (oDictionary, System.Windows.Forms.DragDropEffects:Link).
            END.

            CATCH err AS Progress.Lang.Error:
                ErrorHelper:ShowErrorMessage (err) .
            END CATCH.

        END METHOD .
  4. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    16 Dec 2019 in reply to Mike Fechner
    Link to this post
    I will take a look at this. Thanks for the pointer.
4 posts, 0 answered