如何在Winforms C#中的ListView中使用超链接 [英] How to use hyperlink inside ListView in Winforms C#

查看:43
本文介绍了如何在Winforms C#中的ListView中使用超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 3-4 列的简单 ListView.其中一列有一个电子邮件地址.我希望能够按下该电子邮件地址并打开与电子邮件(很可能是 Outlook)相关的任何程序.

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).

有没有办法在没有外部 ListView 的情况下实现这一目标?

Is there a way to achieve that without external ListView?

推荐答案

试试这个

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);
  }
}

电子邮件格式为:user@domain.com

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

这篇关于如何在Winforms C#中的ListView中使用超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆