2012-07-05 122 views
0

我在datagridview窗體窗體(內置在Visual Basic中)中有一個MySQL表。我的表中的列一旦在每一行都有電子郵件地址。我希望用戶能夠點擊單元格,它會自動從Outlook中打開一封電子郵件,並在電子郵件的「收件人:」部分填入單元格中的電子郵件地址。在MySQL Datagridview中將單元格內容轉換爲超鏈接

我一直沒有成功將其添加到查詢和類Databindingcomplete。

select name, email, phone, address from t1 where name is like 'A%' 
+0

你是說你還沒有能夠顯示datagridview中的數據?另外,我們可以看到你的選擇陳述嗎? – 2012-07-05 21:37:49

+0

我能夠顯示數據,但我希望顯示在特定列的單元格中的電子郵件地址是可點擊的超鏈接。我很抱歉沒有更清楚。 – 2012-07-05 21:49:27

回答

1

您可以使用datagridview單元格單擊事件。

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 
+0

非常感謝! – 2012-07-06 12:43:14

相關問題