【发布时间】:2013-06-25 13:35:58
【问题描述】:
我收到此错误:Argument 'Expression' cannot be converted to type 'DataGridViewRow'. 我不知道这意味着什么或如何解决它,它发生在这一行:
dt2.Rows(Val(selectedItem))("Position") = dt.Rows(selectedItem.Cells(1).Value)("Mouse Position")
谁能解释一下错误是什么以及如何解决它?
Try
If selectedItems Is Nothing Then
For n = 0 To dt.Rows.Count - 1
dt2.Rows.Add(n)
dt2.Rows(n)("Position") = dt.Rows.Item(n)("Mouse Position")
Next
Else
For Each selectedItem As DataGridViewRow In selectedItems
dt2.Rows.Add(selectedItem)
dt2.Rows(Val(selectedItem))("Position") = dt.Rows(selectedItem.Cells(1).Value)("Mouse Position")
Next
End If
Catch ex As Exception
MsgBox("Error", MsgBoxStyle.Exclamation, "Error!")
End Try
【问题讨论】:
-
堆栈跟踪是什么?
-
您的意思是在(“鼠标位置”)末尾调用
.Value? -
selectedItem 是一个 DataGridViewRow,对吧?什么应该返回表达式 Val(DataGridViewRow) ?
-
我以为只是将该数据表的行和列设置为另一个数据表@Steve中第2列的选定行