Vbscript 如何在DevXtraGrid中找到细胞的心形物?使用Testcomplete

Vbscript 如何在DevXtraGrid中找到细胞的心形物?使用Testcomplete,vbscript,testcomplete,gridcontrol,Vbscript,Testcomplete,Gridcontrol,我正在尝试使用以下代码将单元格从一个DevXtraGrid拖动到另一个DevXtraGrid,而不使用坐标 <code> Sub DragAndDropItems(ReqObjectToMove,DestControl) Dim XPos ,YPos ,dX ,dY LogFolder = Log.CreateFolder("Draging and dropping item ") Log.PushLogFolder(LogFolder) XPos = ReqObjectToMove

我正在尝试使用以下代码将单元格从一个DevXtraGrid拖动到另一个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 

我如何使用这个相应的任何建议将不胜感激

请尝试以下代码:

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
如果使用卡片布局,请使用以下代码:

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

我使用了您提供的这段代码,但我收到一个错误“对象不支持此属性或方法:'devXtraGridControl.MainView.ViewInfo.RowsInfo'”请帮助!这是一个非常奇怪的错误,因为我没有尝试在代码中访问RowsInfo属性。你确定没有更改DragNDropCell例程的代码吗?没有,我没有更改该例程中的任何代码,我只是传递了主网格对象,我只获得了直到MainView方法,我没有进一步获得Viewinfo方法..'grid.MainView.ViewInfo“我遇到的另一个错误如下:类型为“System.Int16”的对象无法转换为类型为“DevExpress.XtraGrid.Columns.GridColumn”可能您的网格控件版本比我的版本多。我建议您联系供应商支持()。