Convert Cell Content to Hyperlink in MySQL Datagridview

被刻印的时光 ゝ 提交于 2019-12-25 16:57:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!