如何在c#.net和圆形按钮中制作圆形窗口形式 [英] how to make a round window form in c# .net and round Buttons
本文介绍了如何在c#.net和圆形按钮中制作圆形窗口形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#.net中制作圆形窗口形式
how to make a round window form in c# .net
推荐答案
我假设您是在谈论Windows形式的圆角.
C#Winforms中的圆角表格. [ ^ ]
您可以使用Graphics类来覆盖Onpaint
表格的方法(在表格上打印的地方),您可能需要阅读以下内容
使用GDI类.
这是 GDI +初学者教程 [ Rectangle.Round方法 [ ^ ]供参考.
I assume you''re talking about rounded corners for windows forms.
Rounded Corner Form in C# Winforms.[^]
You can use the classes of Graphics to override the Onpaint
method of the form ( where the form is printed ) you may need to read about
using GDI classes.
Here is good example on GDI+ Tutorial for Beginners[^]
Also have a look on Rectangle.Round Method[^] for reference.
protected void RePaint()
{
GraphicsPath graphicpath = new graphicsPath();
graphicpath.StartFigure();
graphicpath.AddArc(0,0,25,25,180,90);
graphicpath.AddLine(25,0,this.Width-25,0);
graphicpath.AddArc(this.Width-25,0,25,25,270,90);
graphicpath.AddLine(this.Width,25,this.Width,this.Height-25);
graphicpath.AddArc(this.Width-25,this.Height-25,25,25,0,90);
graphicpath.AddLine(this.Width-25,this.height,25,this.Height);
graphicpath.AddArc(0,this.Height-25,25,25,90,90);
graphicpath.CloseFigure();
this.Region = new Region(graphicpath)
}
那不是太困难-您所需要做的就是修改Region属性:
That''s not too difficult - all you need to do is modify the Region property:
GraphicsPath path = new GraphicsPath();
path.AddEllipse(new Rectangle(0, 0, 300, 300));
Region = new Region(path);
但是,这从来没有那么简单!如果您制作圆形(甚至按钮),则必须自己绘制所有图形:标题栏,关闭按钮,边框,拉伸箭头,批次.
However, it is never that simple! If you make a round form (or even button) you are going to have to do all the drawing yourself: title bar, close button, borders, stretch arrows, the lot.
这篇关于如何在c#.net和圆形按钮中制作圆形窗口形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文