Forum Discussion

aminsaurabh's avatar
aminsaurabh
Occasional Contributor
11 years ago
Solved

Drag and Drop without using cordinate system

i am currently trying to Drag an object in a Cell from one DevXtraGridcontrol to another cell on another cell in DevXtraGridcontrol. how i can implement it in Vbscript please help



Alternatively how can we find the Cordinates of a particular cell of a DevXtraGridcontro ?

  • Hi Saurabh,


     


    The code below identifies the coordinates of the cell and drags it. You can try creating you own Drag function based on it.


     




    'VBScript


    Sub Test


      Set grid = Sys.Process("GridMainDemo").WinFormsObject("frmMain").WinFormsObject("panelControl1").WinFormsObject("gcContainer")._

         WinFormsObject("TableView").WinFormsObject("gridControl1")


      Sys.Process("GridMainDemo").WinFormsObject("frmMain").Activate


      Call DragNDropCell(grid, 2, 3, 5, 2)


    End Sub


     


    Sub DragNDropCell(grid, sourceRow, sourceCol, destRow, destCol)


      Set source = grid.MainView.ViewInfo.GetGridCellInfo_2(sourceRow, sourceCol) 


      Set dest = grid.MainView.ViewInfo.GetGridCellInfo_2(destRow, destCol) 


      x = source.Bounds.Left + source.Bounds.Width / 2


      y = source.Bounds.Top + source.Bounds.height / 2


      dX = dest.Bounds.Left - source.Bounds.Left + dest.Bounds.Width / 2


      dY = dest.Bounds.Top - source.Bounds.Top + dest.Bounds.Height / 2


     


      Call grid.Drag(x, y, dX, dY)


    End Sub



2 Replies


  • function dragAndDrop(fromObject, toObject){  


      var fromX = getXPosition(fromObject);


      var fromY = getYPosition(fromObject);


      


      var toX = getXPosition(toObject);


      var toY = getYPosition(toObject);


      


      fromObject.Drag(10,10, toX-fromX, toY-fromY);


    }



    ----





    function getXPosition(object){

      return object.WindowToScreen(10, 10).X;


    }


     


    function getYPosition(object){


      return object.WindowToScreen(10, 10).Y;


    }


     


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Saurabh,


     


    The code below identifies the coordinates of the cell and drags it. You can try creating you own Drag function based on it.


     




    'VBScript


    Sub Test


      Set grid = Sys.Process("GridMainDemo").WinFormsObject("frmMain").WinFormsObject("panelControl1").WinFormsObject("gcContainer")._

         WinFormsObject("TableView").WinFormsObject("gridControl1")


      Sys.Process("GridMainDemo").WinFormsObject("frmMain").Activate


      Call DragNDropCell(grid, 2, 3, 5, 2)


    End Sub


     


    Sub DragNDropCell(grid, sourceRow, sourceCol, destRow, destCol)


      Set source = grid.MainView.ViewInfo.GetGridCellInfo_2(sourceRow, sourceCol) 


      Set dest = grid.MainView.ViewInfo.GetGridCellInfo_2(destRow, destCol) 


      x = source.Bounds.Left + source.Bounds.Width / 2


      y = source.Bounds.Top + source.Bounds.height / 2


      dX = dest.Bounds.Left - source.Bounds.Left + dest.Bounds.Width / 2


      dY = dest.Bounds.Top - source.Bounds.Top + dest.Bounds.Height / 2


     


      Call grid.Drag(x, y, dX, dY)


    End Sub