开发者

How to use hyperlink inside ListView in Winforms C#

开发者 https://www.devze.com 2023-02-13 07:34 出处:网络
I have simple ListView with 3-4 columns. One of the columns have an email address. I would like to be able to press that email address 开发者_如何学编程and open up any program which is associated with

I have simple ListView with 3-4 columns. One of the columns have an email address. I would like to be able to press that email address 开发者_如何学编程and open up any program which is associated with emails (most likely Outlook).

Is there a way to achieve that without external ListView?


Try this

private void listView1_MouseClick(object sender, MouseEventArgs e)
{
  try {
    string mailtoLink = "mailto:"+listView1.SelectedItems[0].SubItems[email_Column].Text;
    System.Diagnostics.Process.Start(mailtoLink);
  } catch(Win32Exception ex) {
    MessageBox.Show("An error has occured: "+ ex.Message);
  }
}

The email is of the format: user@domain.com

0

精彩评论

暂无评论...
验证码 换一张
取 消