How to use hyperlink inside ListView in Winforms C#

守給你的承諾、 提交于 2019-12-11 16:32:36

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/5103133/how-to-use-hyperlink-inside-listview-in-winforms-c-sharp

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