日期:2014-05-18 浏览次数:21012 次
string str = "101 102 103";
private void Form8_Paint(object sender, PaintEventArgs e)
{
Font font = new Font("宋体",10);
Point p = new Point(0,0);
e.Graphics.DrawString(str, font, Brushes.Black, p);
}
private void Form8_Click(object sender, EventArgs e)
{
str += " 104";
this.Refresh();
}
------解决方案--------------------
List<string> str = new List<string>();
int i = 100;
private void button1_Click(object sender, EventArgs e)
{
i++;
str.Add(i.ToString ());
this.Invalidate();
}
private void Form3_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
for (int i = 0; i < str.Count; i++)
{
g.DrawString(str[i], new Font("宋体", 12), Brushes.Black, 10 + 30 * i, 20);
}
}
private void Form3_Load(object sender, EventArgs e)
{
str.Clear();
}