C#在文本框输入文字,单击按钮,在picturebox图片上显示,在文本框重新输入文字,图片上文字被新的代替
下面这个怎么改privatevoidbutton2_Click(objectsender,EventArgse){if(textBox1.Text!=""){Graphi...
下面这个怎么改
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Graphics myg = pictureBox1.CreateGraphics();
SolidBrush mybrush = new SolidBrush(Color.Red);
Font myfont = new Font("黑体", 20);
myg.DrawString(textBox1 .Text , myfont, mybrush, new Rectangle(120, 5, 280, 120));
}
else
{
MessageBox.Show(this, "wenzi", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
} 展开
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Graphics myg = pictureBox1.CreateGraphics();
SolidBrush mybrush = new SolidBrush(Color.Red);
Font myfont = new Font("黑体", 20);
myg.DrawString(textBox1 .Text , myfont, mybrush, new Rectangle(120, 5, 280, 120));
}
else
{
MessageBox.Show(this, "wenzi", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
} 展开
2个回答
展开全部
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Graphics myg = pictureBox1.CreateGraphics();
gp.Clear(pictureBox1.BackColor);//加一句这个
SolidBrush mybrush = new SolidBrush(Color.Red);
Font myfont = new Font("黑体", 20);
myg.DrawString(textBox1 .Text , myfont, mybrush, new Rectangle(120, 5, 280, 120));
}
else
{
MessageBox.Show(this, "wenzi", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |