2012-07-05 69 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

相关问题