额,,博客生涯不会就这样啥也不会的开始吧,哎,,有啥用呢?目前不知道,可能是因为本人是一个电脑小白中的电脑大白吧,哈哈,不过没关系,有大神的帮助,以及对着计算机有着一种特殊的兴趣相信我这个电脑大白会一步步的走向电脑小白的,,,慢慢的填空脑中的那种一片茫然的感觉特爽也,哈哈,不错,继续前进,有学就行。
好吧。是该记录点有用点的东西了。不要再bibi了。
以下是本人做的第一个程序,额 好吧。是弄明白的程序。。。
如何控制能让一个标志性的物体在一个窗口里弹来弹去,
namespace WindowsFormsApplication1.number3
{
public partial class Form1 : Form
{
int ox, oy;
public Form1()
{
InitializeComponent();
button1.Text = "我就点";
label1.Text = "别点";
ox = oy = 1;
}
private void button1_Click(object sender, EventArgs e)
{
if (timer1. Enabled)
timer1. Stop();
else
timer1 .Start() ;
}
private void timer1_Tick(object sender, EventArgs e)
{
Random a = new Random ();
if (oy == -1 &&
label1 .Location .Y < 0)
oy = 1;
if ((label1.Location.X + label1 .Width > this .ClientRectangle.Width) && ox == 1)
ox = -1;
if ((label1 .Location .Y +this .label1 .Height > this .ClientRectangle.Height) && oy == 1)
oy = -1;
if (label1 .Location .X < 0 && ox ==-1)
ox = 1;
label1.Location = new Point(label1.Location .X + ox * a .Next(10) , label1.Location.Y + oy * a .Next(10) );
}
}
}
就这样,,一个简单而对我这小白哦不是大白就困难的程序就这样诞生了,,哈哈哈哈,。
6990

被折叠的 条评论
为什么被折叠?



