if(secureRect.Contains(e.X,e.Y)//矩形区域包含鼠标
            {
                this.Cursor = Cursors.Hand;
               
                if(单击鼠标)
                {
                     Form2 f=new form2();
                     f.ShowDialog;
                     this.Closed();
                }
              请问里面那个“单击鼠标”怎么判断???
                我的意思就是这,如果你有好的方法也可以留下,急用!!!谢谢

解决方案 »

  1.   

    mouseclick事件if(e.Button==MouseButtons.Left)
      

  2.   


    this.Cursor = Cursors.Hand; //rect 属性里设置private void Rect_MouseClick(object sender, MouseEventArgs e)
    { if (e.Button == MouseButtons.Left)
     {
         Form2 f=new form2(); 
         f.ShowDialog(); 
         //this.Closed(); 
     }} 
      

  3.   

    我上面的代码是包含在鼠标移动事件中的,我想要的目的是:当鼠标在那个范围内时,鼠标变成手型,如果再单击,那么将发生
      Form2 f=new form2(); 
                        f.ShowDialog; 
                        this.Closed(); 
      

  4.   

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        bool isInRect = false;
            protected override void OnMouseMove(MouseEventArgs e)
            {
                base.OnMouseMove(e);
                if (e.X > 3 && e.X < 20 && e.Y > 3 && e.Y < 20)
                {
                    Cursor = Cursors.Hand;
                    isInRect = true;
                }
                else
                {
                    isInRect = false;
                    Cursor = Cursors.Default;
                }
            }
            protected override void OnMouseClick(MouseEventArgs e)
            {
                base.OnMouseClick(e);
                if (isInRect && e.Button == MouseButtons.Left)
                {
                    MessageBox.Show("click in rect.");
                }
            }
        }
      

  5.   

    为了测试我用了一下代码
    if (secureRect.Contains(e.X, e.Y))
                {
                    this.Cursor = Cursors.Hand;
                   
                    if (e.Button == MouseButtons.Left)
                    {                    button1.Text = "123456";
                    }
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
    但在矩形区域时,
    总是单击左键多次才会出现button1.Text = "123456";
    很少有单击一次成功的,这是为什么呀???牛人赶紧帮忙解决,完了结贴了,呵呵@@@