代码没有问题,是坐标位置超出了pictureBox的范围        public delegate void Paintp();
        public event Paintp p;
        protected override void OnPaint(PaintEventArgs e)//绿色
        {
            PointF pf = new PointF(0, 0);   //注意文字显示的坐标位置
            using (Graphics g = pictureBox1.CreateGraphics())
            {
                Font f = new Font("Arial", 12);
                g.DrawString("Hello!", f, Brushes.Green, pf);
            }
        }

解决方案 »

  1.   

    http://bbs.csdn.net/topics/390345508看下这个 就是在 pic写字的..
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing.Drawing2D;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e) //用按钮在pictureBox1内写字
            {
                Graphics g = pictureBox1.CreateGraphics();
                Brush ft=new  SolidBrush(Color.FromArgb(100, 200, 30));
                Point p=new Point (0,100);
                g.DrawString("在这里写字!",new Font ("宋体",20),ft,p );
            }        private void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                Graphics g = e.Graphics;
                Brush ft = new SolidBrush(Color.FromArgb(100, 200, 30));
                Point p = new Point(45, 45);
                g.DrawString("这是pictureBox1_Paint写字!", new Font("宋体", 20), ft, p);
            }        private void button2_Click(object sender, EventArgs e)
            {
                Graphics g = this.CreateGraphics();
                Brush ft = new SolidBrush(Color.FromArgb(100, 200, 30));
                Point p = new Point(0, 0);
                g.DrawString("这是在窗体上里写字!", new Font("宋体", 20), ft, p);
            }
        }
    }
      

  3.   

    protected override void OnPaint(PaintEventArgs e)//绿色请注意override的是窗体的OnPaint!
      

  4.   

    仅供参考:onPaint的参数e中有graphic,e.Graphics 请用它来绘制。
    不要忘记调用base.onPaint(e);附:修改你的代码protected override void OnPaint(PaintEventArgs e)
            {
                PointF pf = new PointF(200, 200);
                Font f = new Font("Arial", 12);
                e.Graphics.DrawString("Hello!", f, Brushes.Green, pf);
                base.OnPaint(e);
            }
      

  5.   

    using (var _Graphics = this.pictureBox1.CreateGraphics()) {
     var _BSolid  = new SolidBrush(Color.Black);   
    _Graphics.DrawString("欲输出内容", this.Font, _BSolid ,ClientSize.Width - 60, 20);
    _BSolid.Dispose();
     }
    // 做好释放优化工作,别想到现在电脑内存大了硬件配置高了
    // 软件是要求越来越快,而不是搞得越来越慢,除非你愿意写垃圾代码