C〓〓〓マウスを取得してlistviewの右ボタンでセルの内容の方法をクリックします。


コントロールを右クリックすると、選択した項目のテキストの内容が分かります。
右クリック時のセルのテキストのみを取得することを要求します。
方法は以下の通りです
1、グローバルマウスの状態を指定します。
Point m_MBRpt;//マウスの右クリック時Point
2、マウスを操作して押す時のlistViewでのメッセージ

private void listView1_MouseDown(object sender, MouseEventArgs e)
    {
      //
      if (e.Button==MouseButtons.Right)
      {
        //          ,           
        m_MBRpt = listView1.PointToClient(Control.MousePosition);
      }

    }
3、右クリックメニュー--コピー項目のメッセージ

private void COPYITEM_Click(object sender, EventArgs e)
    {
      //            
      if (listView1.SelectedItems.Count <= 0)
      {
        MessageBox.Show("        !", "  ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        return;
      }

      //          ,           (             )
      //Point pt = listView1.PointToClient(m_MBRpt);

      ListViewItem lstrow = listView1.GetItemAt(m_MBRpt.X, m_MBRpt.Y);
      System.Windows.Forms.ListViewItem.ListViewSubItem lstcol = lstrow.GetSubItemAt(m_MBRpt.X, m_MBRpt.Y);
      string strText = lstcol.Text;
      //      
      SetClipboardText(strText);

    }
4、貼り付け板の内容の設定

 public void SetClipboardText(string strText)
    {
      try
      {
        Clipboard.SetDataObject(strText);
      }
      catch (System.Exception ex)
      {
        MessageBox.Show(ex.Message, "  ", MessageBoxButtons.OK, MessageBoxIcon.Error);      
      }
      
    }

以上のC〓〓〓はマウスを取ってlistviewの右ボタンでセルの内容の方法をクリックするのは小さい編集がみんなのすべての内容に分かち合うので、みんなに1つの参考をあげることができることを望んで、みんながよけいに私達を支持することをも望みます。