Hi,
you wired your Paint event in a way that the drawing is actually happening on the form, not the picturebox. To draw the text on a picturebox, modify your code like:
public partial class Form1 : Form
{
private String drawString = "Sample Text";
private Font drawFont = new Font("Arial", 31);
private SolidBrush drawBrush = new SolidBrush(Color.White);
private int textX = 0;
public Form1()
{
InitializeComponent();
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 1;
timer1.Enabled = true;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString(drawString, drawFont, drawBrush, new PointF(textX++, 0));
}
private void timer1_Tick(object sender, EventArgs e)
{
this.pictureBox1.Invalidate();
}
}
Andrej