c#新手提问,求赐教

来源:百度知道 编辑:UC知道 时间:2024/06/14 03:13:52
新手做winform,需要实现这样的功能:一个button,当form1启动的时候,button显示的text是“开始”,当点击“开始”时,程序运行一段内容(一个图片走动),此时button显示“暂停”;当点击“暂停”时,这个程序暂停运行(这个图片停止走动);此时button变成“继续”,如果点击,测图片继续走动。

这个我是在不知道怎么实现了。。。

跪求啊。。。。

我只有50,就给30分吧。。
1楼哥哥能详细点么?我是新手。

mingrui972,你说的在if循环中会出现死循环。

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
if(this.button1.Text == "开始" || this.button1.Text == "继续")
{
this.timer1.Enabled = true;
this.button1.Text = "暂停";
}
else
{
this.timer1.Enabled = false;
this.button1.Text = "继续";
}