I'm loading a DataSet
into a DataGridView
. The data is a hyperlink
to a file on the local network but I can't get the link to actually launch the file. Do I have to go into the clickevent
and actually launch it from there? Or is there a property I can set on the DataGridViewLinkCell
to do it without the fuss?
Thanks, code is below.
'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
If I did go clickevent
route I think it would be something like this but it doesn't work very well but I haven't tried much yet:
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
Yes you need to handle the click event and launch the URL in code (Process.Start
)