我在按钮上绘制一个圆/椭圆有一些问题,因为我将它们绘制在表单上而不是按钮本身意味着它们最终会被按钮覆盖。
现在我像这样绘制椭圆
Pen green = new Pen(Color.Green, 1);
Rectangle rectEllipse = new Rectangle(100, 40, 30, 30);
e.Graphics.DrawEllipse(black, rectEllipse);
答案 0 :(得分:2)
您必须使用Button
,而不是Form
:
private void myButton_Paint(object sender, PaintEventArgs e) {
//DONE: wrap IDisposable into using
using (Pen green = new Pen(Color.Green, 1)) {
Rectangle rectEllipse = new Rectangle(10, 10, 30, 30);
// typo? You, probably, mean "green", not "black"
e.Graphics.DrawEllipse(green, rectEllipse);
}
}