问题
I have a MySQL table in datagridview windows form (built in visual basic). Once column in my table has email addresses in every row. I would like the users to be able to click on the cell and it will automatically open an email message from Outlook with the email address in the cell populated in the 'to:' section of email.
I've been unsuccessful adding it into the query and in the class Databindingcomplete.
select name, email, phone, address from t1 where name is like 'A%'
回答1:
You can use the datagridview cell click event.
Private Sub MyDataGridView_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles MyDataGridView.CellClick
If MyDataGridView.Columns(e.ColumnIndex).HeaderText = "email" then
Dim selectedEMailCell As DataGridViewCell = MyDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex)
If selectedEMailCell.Value IsNot Nothing Then
System.Diagnostics.Process.Start("mailto:" & selectedEMailCell.Value.ToString)
End If
End If
End Sub
来源:https://stackoverflow.com/questions/11352761/convert-cell-content-to-hyperlink-in-mysql-datagridview