婚礼策划网 加入收藏  -  设为首页
您的位置:婚礼策划网 > 婚礼旅行 > 正文
C#如何实现图片按钮上图片的移动
C#如何实现图片按钮上图片的移动
提示:

C#如何实现图片按钮上图片的移动

private void button1_Click(object sender, EventArgs e)
{
int x = 300;
int y = 200; //指定移动的位置
for (int i = 0; i < 100; i++)
{
pictureBox1.Location = new Point(pictureBox1.Location.X + x/100, pictureBox1.Location.Y + y/100);
System.Threading.Thread.Sleep(100);
}
}

c#中怎么实现点击窗体中的按钮绘图
提示:

c#中怎么实现点击窗体中的按钮绘图

private void button1_Click(object sender, EventArgs e)
{

Graphics g = CreateGraphics();//改变这个就行
using (Pen bluePen = new Pen(Color.Blue, 1))
{
if (ClientRectangle.Height / 10 > 0)
{
for (int y = 0; y < ClientRectangle.Height; y += ClientRectangle.Height / 10)
{
g.DrawLine(bluePen, new Point(0, 0), new Point(ClientRectangle.Width, y));
}
}
}
}