【发布时间】:2016-08-06 17:29:36
【问题描述】:
我正在将DataSet 加载到DataGridView 中。数据是本地网络上文件的hyperlink,但我无法获得实际启动文件的链接。我是否必须进入clickevent 并从那里实际启动它?或者有没有我可以在DataGridViewLinkCell 上设置的属性来轻松做到这一点?
谢谢,代码如下。
'dgMain is the DataGridView
dgMain.DataSource = dataSet1.Tables(0)
'Just an example, will format entire column when I'm done
dgMain(10, 1) = New DataGridViewLinkCell
如果我确实走clickevent 路线,我想会是这样,但效果不是很好,但我还没有尝试太多:
Private Sub dgMain_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgMain.CellContentClick
If e.RowIndex = -1 Then
Exit Sub
End If
If dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex) Is DataGridViewLinkCell Then
Process.Start(dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex).ToString)
End If
End Sub
【问题讨论】:
标签: vb.net datagridview dataset datagridviewlinkcolumn