2009年11月29日 星期日

keydown&button&label範例

namespace KEY事件
{
public partial class Form1 : Form
{
public Label Label1;
public Button button1;
public Form1()
{
Label1 = new Label();
Label1.Location = new Point(30, 30);
Label1.Text = "1";
Controls.Add(Label1);
//////////////////////////////////////////////////////////////////////
button1 = new Button();
button1.Location = new Point(60, 60);
button1.Size = new Size(60, 60);
button1.Text = "2";
Controls.Add(button1);
button1.Enabled = false;
/////////////////////////////////////////////////////////////////////////
KeyDown += new KeyEventHandler(Form1_KeyDown);
button1.Click += new System.EventHandler(Button1_Click);
}
void Button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("button_click");
}
void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
}
}
}

沒有留言:

張貼留言