0
我试图从数据网格中的选定行中的单元格获取值,但徒劳无功。我已经能够在windows窗体中的datagridview中轻松完成此操作,但是在wpf数据网格中这种操作不起作用。我试过的代码如下:如何获取vb.net中datagrid中选定行的单元格的值
`If Me.mileGrd.Items.Count > 0 Then
If Me.mileGrd.SelectedItems.Count > 0 Then
MessageBox.Show("check me")
Dim cnum As String = Me.mileGrd.SelectedItems(0).Cells("Car No").Value
'do more stuff here
End If
End If`
mileGrd
是datagrid。 当我运行该程序时,我收到一条错误消息Public member 'Cells' on type 'DataRowView' not found
。我可以用什么方法来读取数据网格中选定行的单元格的值,并在此例中使用列标题作为参数,如Car No
?任何帮助表示赞赏。
感谢您的回复。我在使用该代码时遇到错误。你确定它有效吗?也许可以解释一下。首先我看到'DataGridViewRow',但我正在使用'DataGrid' – ken