zoukankan      html  css  js  c++  java
  • C# Winform ListView实现单元格双击复制内容到剪贴板

            private void listView_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                ListView listview = (ListView)sender;
                ListViewItem lstrow = listview.GetItemAt(e.X, e.Y);
                System.Windows.Forms.ListViewItem.ListViewSubItem lstcol = lstrow.GetSubItemAt(e.X, e.Y);
                string strText = lstcol.Text;
                try
                {
                    Clipboard.SetDataObject(strText);
                    notifyIcon1.Visible = true;
                    string info = string.Format("内容【{0}】已经复制到剪贴板", strText);
                    notifyIcon1.ShowBalloonTip(1500, "提示", info, ToolTipIcon.Info);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }


    图示:双击“塑胶工程师”单元格会将内容复制到剪贴板中,并在右下角冒泡提示(使用NotifyIcon时必须设置ICON属性,否则不显示)


  • 相关阅读:
    指数
    汉诺塔问题
    只用递归和当前的栈实现栈的逆序
    让你996的不是你的老板,而是其他愿意996的人
    luke towan
    2020-9-3
    2020-9-3
    springboot注解
    2020-9-2
    20200827
  • 原文地址:https://www.cnblogs.com/apollokk/p/6713801.html
Copyright © 2011-2022 走看看