我想在我的按钮上画一个椭圆,表单应用程序C#
我在我的按钮上面画一个圆/椭圆有一些问题,因为我把它们画在窗体上,而不是按钮本身,这意味着它们最终会被按钮覆盖 现在我像这样画椭圆我想在我的按钮上画一个椭圆,表单应用程序C#,c#,forms,C#,Forms,我在我的按钮上面画一个圆/椭圆有一些问题,因为我把它们画在窗体上,而不是按钮本身,这意味着它们最终会被按钮覆盖 现在我像这样画椭圆 Pen green = new Pen(Color.Green, 1); Rectangle rectEllipse = new Rectangle(100, 40, 30, 30); e.Graphics.DrawEllipse(black, rectEllipse); 您必须在按钮上绘图,而不是在表格上绘图: private void myB
Pen green = new Pen(Color.Green, 1);
Rectangle rectEllipse = new Rectangle(100, 40, 30, 30);
e.Graphics.DrawEllipse(black, rectEllipse);
您必须在
按钮
上绘图,而不是在表格
上绘图:
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);
}
}
实际上,我有2支钢笔,我只是复制了错误的代码行。我如何将功能连接到我的按钮?@c7nt:您必须指定要在其上绘制的按钮的
事件