this.Region = new Region(path);path是一个GraphicPath类型的对象,这个对象里面楼主可以添加封闭曲线组成控件的边界 path.Add...(...);
如果要改变形状的话。private void Form1_Paint(object sender, PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = this.button1.ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(-10, -10); // Draw the button's border. e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. this.button1.Region = new System.Drawing.Region(buttonPath); }
我说的就是3楼的那个意思,3楼说的下面两句:buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. this.button1.Region = new System.Drawing.Region(buttonPath);就是让按钮变成椭圆形的,楼主没明白?
path.Add...(...);
{
System.Drawing.Drawing2D.GraphicsPath buttonPath =
new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's
// ClientRectangle property.
System.Drawing.Rectangle newRectangle = this.button1.ClientRectangle; // Decrease the size of the rectangle.
newRectangle.Inflate(-10, -10); // Draw the button's border.
e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); // Increase the size of the rectangle to include the border.
newRectangle.Inflate(1, 1); // Create a circle within the new rectangle.
buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created
// circle region.
this.button1.Region = new System.Drawing.Region(buttonPath); }
// circle region.
this.button1.Region = new System.Drawing.Region(buttonPath);就是让按钮变成椭圆形的,楼主没明白?
再看看每一句的注释就应该差不多了吧。
该控件自带多种界面.用法也很简单
把设置一下this.skinEngine1.SkinFile=你的ssk文件即可.
如果需要,留下Email
发给你
Regionimagebutton皮肤控件还有用背景图片
把button的一个属性改为transparent