e.Graphics.DrawString("现在的时间是"+dTime.ToString(),new Font("Curior New",18f),new SolidBrush(Color,Black),50f,100f.null);源代码
using System;using System.Drawing;
using System.Windows.Forms;
    public  class PresentTimeForm : System.Windows.Forms.Form
    {
        DateTime dTime;
        public PresentTimeForm()
        {
            this.ClientSize = new System.Drawing.Size(500, 200);
            this.Text = "what time is it now?";
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.PresentTimeForm_Paint);        }
        static void Main() {
            Application.Run(new PresentTimeForm());
        }
        private void PresentTimeForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {            dTime = DateTime.Now;
            e.Graphics.DrawString("现在的时间是"+dTime.ToString(),new Font("Curior New",18f),new SolidBrush(Color,Black),50f,100f.null);
        }
    }

解决方案 »

  1.   

     using (Font ft = new Font("Curior New", 18f))
                {
                    using (Brush bs = new SolidBrush(Color, Black))
                    {
                        e.Graphics.DrawString("现在的时间是" + dTime.ToString(), ft, bs, 50f, 100f);
                    }
                }
                //或
                using (Font ft = new Font("Curior New", 18f))
                {
                    e.Graphics.DrawString("现在的时间是" + dTime.ToString(), ft, Brushes.Black , 50f, 100f);
                }你原来的代码100f.null处是语法错误.GDI对象在new出来后,一定要调用Dispose()方法,或使用using块去自动调用Dispose方法.否则你的软件如果常时间运行的话,可能把系统的GDI资源全部耗尽.