button 控件的 移动 以前用vb 作过一个小程序 就是在窗体上 有个button 当鼠标移到button 上时 button 会随即移动到别的地方 (就是让鼠标永远也点不到button)。在c#里试过 button.move 了不过 不行 。。刚刚接触 c# 那位 能给指点一下 先谢了。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试MouseEnter事件,直接修改button.Location MouseEnter事件,表示鼠标移到按钮上时发生事件private void button1_MouseEnter(object sender, EventArgs e){ Random r = new Random(); this.button1.Left = r.Next(this.Width); this.button1.Top = r.Next(this.Height);} 参考如下代码:private Point[] btnLocations = { new Point(10, 10), new Point(100, 100), new Point(150, 20) };private int index = 0;private void Form1_Load(object sender, EventArgs e){ button1.Location = btnLocations[index];}private void button1_MouseEnter(object sender, EventArgs e){ index = (index + 1) % btnLocations.Length; button1.Location = btnLocations[index]; } 解决了 谢谢 几位 用buton.left 和button.top 就可以重新定义button 的位置了 谢谢大家帮忙 ^_^ 未处理的 "System.IndexOutOfRangeException" 正则-匹配连续数字 发现使用Xenocode\混淆后的程序 关于ArrayList的几个简单问题 怎样在卸载的时候不卸载某一个安装的文件? 请问谁知道c#下如何进行验证码的识别?识别率高点的 类成员继承问题 问个简单的问题!~~~ 问什么这个Url会引起Uri错误?? 一个combobox选择如何使另一个combobox的选项改变(100分)? 关于DataGirdView中对正在输入的数据值的访问 当鼠标在窗体之外时如何捕获鼠标的移动事件
{
Random r = new Random();
this.button1.Left = r.Next(this.Width);
this.button1.Top = r.Next(this.Height);
}
private Point[] btnLocations = { new Point(10, 10),
new Point(100, 100), new Point(150, 20) };
private int index = 0;private void Form1_Load(object sender, EventArgs e)
{
button1.Location = btnLocations[index];
}private void button1_MouseEnter(object sender, EventArgs e)
{
index = (index + 1) % btnLocations.Length;
button1.Location = btnLocations[index];
}