C#
C#请教高手:在一个按钮中处理开始与结束两个事件,应该点做呢?
程序代码:/*
* Created by SharpDevelop.
* User: hellson
* Date: 2008-10-8
* Time: 17:00
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace draws
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm
{
Form f = new Form();
bool begin = true;
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
label1.Text = "等待开始被按下";
button1.Text ="开始";
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
private void Button1Click(object sender, EventArgs e)
{
if(begin)
callbegin();
else callend();
begin = !begin;
}
void callbegin()
{
label1.Text = "等待<开始>被按下";
button1.Text ="开始";
}
void callend()
{
label1.Text = "等待<停止>被按下";
button1.Text ="停止";
}
}
}
