我想在c#的picturebox上画图,用DrawEllipse画点为什么picturebox上没有反应。
我想在c#的picturebox上画图Pointmypoint=newPoint();privatevoidpictureBox1_MouseDown(objectsen...
我想在c#的picturebox上画图
Point mypoint=new Point();
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
为什么picturebox没有什么反应呢
再添加一句
Point mypoint=new Point();
bool isok;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isok=true;
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if(isok==true)
{ Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
}
但是picturebox没有什么反应呢 展开
Point mypoint=new Point();
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
为什么picturebox没有什么反应呢
再添加一句
Point mypoint=new Point();
bool isok;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isok=true;
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if(isok==true)
{ Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
}
但是picturebox没有什么反应呢 展开
展开全部
设计视图时,点击pictureBox的事件列表,看看相应的事件是否加上了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
添加个控件timer
用tick事件代替paint事件就可以了
用tick事件代替paint事件就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果代码没问题,那么是不是没有Invalidate()?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询