【www.gdgbn.com--窗口特效】

为了让学生对事件有一个初步的印象,特意设计了一个趣味程序,界面较简单,就是提一个简单的问题,要你点Yes或No按钮来回答问题。但当你去点Yes按钮的时候,这个Yes按钮会满窗口的跑,不让你去点它。
  这个趣味程序是在教学过程中临时穿插进去的。使用这个程序的目的,是让学生对C#中对事件的处理有一个初步的印象,了解事件要经过注册和实现这两步,另外通过这个趣味程序,让学生了解Random类和Point类的使用。
  本程序的全部代码如下,请注意红字的代码,其余的代码都是设计器自动生成的。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace LoveMe
{
///
/// Form1 的摘要说明。
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button yesButton;
private System.Windows.Forms.Button noButton;
///
/// 必需的设计器变量。
///

private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();

本文来源:http://www.gdgbn.com/wangyetexiao/4487/