private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
char x;
int sw = 0;
if (e.KeyCode == Keys.Enter)
{
x = Convert.ToChar(textBox1.Text);
int i;
for (i = 0; i < n; i++)
if (x == litere[i]) { lb[i].Text = ""; lb[i].Text = Convert.ToString(x); sw = 1; }
if (sw == 0) { pictureBox1_Paint(???); }
}
}
$
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
wrong++;
Graphics g = CreateGraphics();
Brush b=new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross,Color.White,Color.Black);
if (wrong == 1) g.FillEllipse(b, 250, 125, 30, 30);
}
$ 我不知道如何在文本框的事件中调用Picturebox_paint函数...或者如果不可能,我怎样才能从图片框中绘制内容?
答案 0 :(得分:1)
++有很多错误。但是你开始用它来修复它:
if (sw == 0) pictureBox1.Invalidate();
答案 1 :(得分:0)
也许你应该创建一个方法:
private void redraw()
{
wrong++;
Graphics g = CreateGraphics();
Brush b=new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross,Color.White,Color.Black);
if (wrong == 1) g.FillEllipse(b, 250, 125, 30, 30);
}
并且您可以在任何地方使用它
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
redraw();
}
和
...
if (sw == 0) { redraw(); }
...