【发布时间】:2016-07-05 08:49:26
【问题描述】:
我正在使用 WPF 和 Visual Basic。我试图有一个按钮,允许从我拥有的 DataGrid 复制。我所做的一切似乎都不允许我访问所选数据,并使用仅在 DataGrid 上触发复制事件的替代方法,我不知道如何。这是一个这样的失败代码示例:
Private Sub btnFECopy_Click(sender As Object, e As RoutedEventArgs) Handles btnFECopy.Click
Dim text As New System.Text.StringBuilder()
For Each row As DataGridCellInfo In dgFileEditorWindow.SelectedCells
For Each cell As System.Data.DataRowView In row.Item
If Not text.Equals("") Then
text.Append(";")
End If
text = text.Append(cell.ToString)
'MsgBox(cell.Column.DisplayIndex)
'MsgBox(dataGrid1.Items.IndexOf(cell.Item))
Next
Next
'Nothing text.Append(dgFileEditorWindow.CurrentCell.Item.ToString())
'Nothing Console.WriteLine(dgFileEditorWindow.CurrentCell.ColumnNumber & " " & dgFileEditorWindow.CurrentCell.RowNumber)
Clipboard.SetText(text.ToString())
End Sub
有什么提示吗?
【问题讨论】:
标签: wpf vb.net datagrid copy-paste