//记得using System.Drawing.Drawing2D;private void button1_Click(object sender, EventArgs e)
{
  Graphics g = pictureBox1.CreateGraphics();
  g.DrawRectangle(new Pen(Color.AntiqueWhite,3),0,0,118,270);
  g.SmoothingMode = SmoothingMode.HighQuality;
  g.DrawString("sg.com.cn",
      new Font("Arial", 10, FontStyle.Bold|FontStyle.Italic),
          SystemBrushes.ActiveCaptionText,
          new PointF(10,10));
}

解决方案 »

  1.   

    你是不是把上面的代码写到Form_Load里面了?那样肯定先是不出来,如果那样你需要自己重写pictureBox控件
    添加一个组建类 如(picture.cs)
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Windows.Forms;
    using System.Drawing.Drawing2D;
    在那个类中添加以上名字空间
    在重载 OnPaint事件
    protected override void OnPaint(PaintEventArgs e)
    {
    Graphics g =e.Graphics;
    Font fn =new  Font("Ariel" , 9 , FontStyle.Bold );
    SolidBrush brush=new SolidBrush(Color.Red);
    g.DrawString("test",fn,brush,0,0);
    base.OnPaint(e);
    }然后再你的那个Form的Form_Load中加入一下代码就OK了
    private void Form1_Load(object sender, System.EventArgs e)
    {
    picture pic=new picture();
    pic.BackColor=Color.Black;
    pic.Visible=true;
    pic.Location = new System.Drawing.Point(0, 0); this.Controls.AddRange(new System.Windows.Forms.Control[] { pic });
    }