/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
   this.button1 = new System.Windows.Forms.Button();
this.button1.Location = new System.Drawing.Point(560, 320);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
}
private void button1_Click(object sender, System.EventArgs e)

   MessageBox.Show("ok");
}

解决方案 »

  1.   

    添加这个引用
    using System.Runtime.InteropServices;
    接下来是代码:
    [ DllImport("user32") ]
    public static extern System.IntPtr GetDC(System.IntPtr dc);
    System.Drawing.Graphics g; //画图板
    private void button1_Click(object sender, System.EventArgs e)
    {
    //取得句柄
    g=Graphics.FromHdc(GetDC(System.IntPtr.Zero));
    // Create string to draw.
    String drawString = "显示一段文本";
    // Create font and brush.
    Font drawFont = new Font("Arial", 32);
    SolidBrush drawBrush = new SolidBrush(Color.Red);
    // Create point for upper-left corner of drawing.
    float x = 150.0F;
    float y =  50.0F;
    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
    // Draw string to screen.
    g.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
    }
      

  2.   

    这在msdn上有例子的,做了小修改,加了注释,应该容易看懂的
    至于"事件",你设计时,双击产生的就是事件!
      

  3.   

    是要加一个自定义事件吗??可以从EventArgs继承出来,然后在需要截获该事件的地方写
    private void 实现事件的处理(object sender, 自定义事件类 e)当然,需要将事件的委托加入类似this.button1.Click += new System.EventHandler(this.button1_Click);的语句......
      

  4.   

    找本入门的书不是都很清楚了吗?  
    TCE、LCE??