【发布时间】:2015-08-18 10:34:42
【问题描述】:
我正在开发一个 winform 项目(visual c#)。其中一个表单上有许多按钮,它们彼此相邻。我想在这些按钮前面添加图形,以使用户可以继续按下按钮。我不能在后面添加图形,因为按钮隐藏了图形,我不想移动按钮。我试图将控件移到后面,但没有用。有任何想法吗?谢谢!
toPolygon.Insert(toPolygon.Count, button); //insert button to vector
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
myPen.Width = 10;
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.DrawLine(myPen, toPolygon[toPolygon.Count - 2].Location.X, toPolygon[toPolygon.Count - 2].Location.Y,
button.Location.X , button.Location.Y); //draw a line from last button in the vector to the new one
myPen.Dispose();
if (toPolygon.First() == toPolygon.Last())
{
//draw polygon and clean the vector
}
【问题讨论】:
-
如果我错了请纠正我,但如果图形在按钮“前面”,用户将看不到按钮?!?
-
请出示您的代码好吗?
-
Button.Image 或 Paint 事件有什么问题?
-
基本上你是对的,但它仍然满足我的需求。我只会用细“笔”画一个多边形。
-
您不能使用 Image 属性或按钮的绘制事件将图像放在按钮上,就像 taffer 已经提出的那样?还是您想要一个看起来像图像的按钮?在这种情况下,您不能使用带有 onclick 事件的图像控件吗?根本不清楚您要在这里做什么
标签: c# winforms button graphics