c# winform 不得不爱,(控件窗口尺寸)

 

  private void button2_MouseEnter(object sender, EventArgs e) //mouseENter方法,鼠标进入图形部分时
        {
            //根据客户端尺寸变更长短
            int x = this.ClientSize.Width - button2.ClientSize.Width;
            int y = this.ClientSize.Height - button2.ClientSize.Height;
            //随机数 next()
            Random rom = new Random();
            //point为结构
            button2.Location = new Point(rom.Next(0,x),rom.Next(0,y));
        }

  

 

posted @ 2021-04-07 22:40  遥月  阅读(173)  评论(0)    收藏  举报