我正在尝试使用以下代码将单元格从一个DevXtraGrid拖动到另一个不使用坐标
<code>
Sub DragAndDropItems(ReqObjectToMove,DestControl)
Dim XPos ,YPos ,dX ,dY
LogFolder = Log.CreateFolder("Draging and dropping item ")
Log.PushLogFolder(LogFolder)
XPos = ReqObjectToMove.Left+ReqObjectToMove.Width/2
YPos = ReqObjectToMove.Top+ReqObjectToMove.Height/2
dX = DestControl.ScreenLeft - ReqObjectToMove.ScreenLeft
dY = DestControl.ScreenTop - ReqObjectToMove.ScreenTop
Call ReqObjectToMove.Drag(XPos, YPos, dX, dY)
Log.PopLogFolder
End Sub
我怎么能相应地使用这个任何建议将不胜感激。
答案 0 :(得分:1)
试试这段代码:
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
如果您使用卡片布局,请使用以下代码:
Sub Test_CardLayout
Set grid = Sys.Process("GridMainDemo").WinFormsObject("frmMain").WinFormsObject("panelControl1").WinFormsObject("gcContainer").WinFormsObject("CardViewControl").WinFormsObject("gridControl1")
Sys.Process("GridMainDemo").WinFormsObject("frmMain").Activate
Call DragNDropCellCardLayout(grid, 0, 2)
End Sub
Sub DragNDropCellCardLayout(grid, sourceCardIndex, destCardIndex)
Set source = grid.MainView.ViewInfo.Cards.Item(sourceCardIndex)
Set dest = grid.MainView.ViewInfo.Cards.Item(destCardIndex)
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