在MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
里通e.X;e.Y;e.Button可知.
如果是BUTTON的click事件之类是不行的

解决方案 »

  1.   

    我实在listview控键中的click事件,
    不过谢谢你的回复
      

  2.   

    ListView也有MouseDown事件,不要用Click事件就好了。没太大差别
      

  3.   

    再listview中有一些items,右键弹出一个contextmenu,左键谈出另一个,
    双击又谈出一个对话框,
    简单的说,跟qq一样
      

  4.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace listviewclick
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.ContextMenu contextMenu1;
    private System.Windows.Forms.ContextMenu contextMenu2;
    private System.Windows.Forms.ContextMenu contextMenu3;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.MenuItem menuItem3;
    private System.Windows.Forms.Timer timer1;
    private System.ComponentModel.IContainer components; Point curpoint; public enum clicktimes
    {none=0,one=1,two=2}; public enum clickhand
    {none=0,left=1,right=2,doubles=3}; clicktimes ct=clicktimes.none;
    clickhand ch=clickhand.none;
    public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    this.listView1 = new System.Windows.Forms.ListView();
    this.contextMenu1 = new System.Windows.Forms.ContextMenu();
    this.menuItem1 = new System.Windows.Forms.MenuItem();
    this.contextMenu2 = new System.Windows.Forms.ContextMenu();
    this.menuItem2 = new System.Windows.Forms.MenuItem();
    this.contextMenu3 = new System.Windows.Forms.ContextMenu();
    this.menuItem3 = new System.Windows.Forms.MenuItem();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.SuspendLayout();
    // 
    // listView1
    // 
    this.listView1.Name = "listView1";
    this.listView1.Size = new System.Drawing.Size(296, 208);
    this.listView1.TabIndex = 0;
    this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
    // 
    // contextMenu1
    // 
    this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.menuItem1});
    // 
    // menuItem1
    // 
    this.menuItem1.Index = 0;
    this.menuItem1.Text = "左";
    // 
    // contextMenu2
    // 
    this.contextMenu2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.menuItem2});
    // 
    // menuItem2
    // 
    this.menuItem2.Index = 0;
    this.menuItem2.Text = "右";
    // 
    // contextMenu3
    // 
    this.contextMenu3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.menuItem3});
    // 
    // menuItem3
    // 
    this.menuItem3.Index = 0;
    this.menuItem3.Text = "双击";
    // 
    // timer1
    // 
    this.timer1.Interval = 500;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.listView1});
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void listView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    switch (e.Button)
    {
    case MouseButtons.Left:
    switch(ct)
    {
    case clicktimes.none :
    ct=clicktimes.one;
    ch=clickhand.left;
    break;
    case clicktimes.one :
    ct=clicktimes.two;
    ch=clickhand.doubles;
    break;
    case clicktimes.two :
    ct=clicktimes.two;
    ch=clickhand.doubles;
    break;
    }
    break;
    case MouseButtons.Right:
    switch(ct)
    {
    case clicktimes.none :
    ct=clicktimes.one;
    ch=clickhand.right;
    break;
    case clicktimes.one :
    ct=clicktimes.two;
    ch=clickhand.doubles;
    break;
    case clicktimes.two :
    ct=clicktimes.two;
    ch=clickhand.doubles;
    break;
    }
    break;
    } curpoint=new Point(e.X,e.Y);
    timer1.Start();
    } private void timer1_Tick(object sender, System.EventArgs e)
    {
    timer1.Stop();
    switch(ch)
    {
    case clickhand.none :
    break;
    case clickhand.left :
    contextMenu1.Show(listView1,curpoint);
    break;
    case clickhand.right :
    contextMenu2.Show(listView1,curpoint);
    break;
    case clickhand.doubles :
    contextMenu3.Show(listView1,curpoint);
    break;
    }
    ct=clicktimes.none;
    ch=clickhand.none;
    }
    }
    }
    你看有没有实现你的要求。