PART II
C h a p t e r 2 6 :
U s e S y s t e m . W i n d o w s . F o r m s
855
[STAThread]
static void Main() {
ButtonForm skel = new ButtonForm();
Application.EnableVisualStyles();
Application.Run(skel);
}
// Handler for MyButton.
void MyButtonClick(object who, EventArgs e) {
if(MyButton.Top == 200)
MyButton.Location = new Point(10, 10);
else
MyButton.Location = new Point(100, 200);
}
}
Let’s look closely at the event-handling code in this program. The event handler for the
button click is shown here:
// Handler for MyButton.
void MyButtonClick(object who, EventArgs e) {
if(MyButton.Top == 200)
MyButton.Location = new Point(10, 10);
else
MyButton.Location = new Point(100, 200);
}
Do'stlaringiz bilan baham: |