日期:2014-05-20  浏览次数:20911 次

如何做一个六边形,或者三角型的ButtonControl?
如题

------解决方案--------------------
用ImageButton然后做一张六边形,或者三角型的,大小合适图片。然后在属性中把ImageUrl指向你做好的图片就成了
------解决方案--------------------
http://www.codeproject.com/cs/miscctrl/skincontrol.asp

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
------解决方案--------------------
添加一个Paint事件:this.roundButton.Paint += new System.Windows.Forms.PaintEventHandler(this.roundButton_Paint);
然后,MSDN的例子
// This method will change the square button to a circular button by
// creating a new circle-shaped GraphicsPath object and setting it
// to the RoundButton objects region.
private void roundButton_Paint(object sender,
System.Windows.Forms.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 = roundButton.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.
roundButton.Region = new System.Drawing.Region(buttonPath);
}
然后自己把图片换一下就行了


------解决方案--------------------
UP 自己画了
------解决方案--------------------
//参考如下代码,再利用Paint事件可以做到你需要的效果
GraphicsPath vGraphicsPath = new GraphicsPath();
button1.Width = 100;
button1.Height = 100;
Point[] vPoints = { new Point(50, 0), new Point(100, 100), new Point(0, 100)
vGraphicsPath.AddPolygon(vPoints);
button1.Region = new Region(vGraphicsPath);

------解决方案--------------------
using System.Drawing.Drawing2D; //GraphicsPath
------解决方案--------------------
winform的话,可以用picturebox控件的click事件来代码button的事件,你可以找一个想要的图片,然后把picturebox的背景设为透明就可以了。
------解决方案--------------------
帮LZ顶
------解决方案--------------------
mark一下
帮顶
------解决方案--------------------
难道我的代码白贴了?楼主调试过没有?有什么问题吗?
------解决方案--------------------
在OnPaint中绘图,你想要什么形状就什么形状。

在OnClick中作命中判断,如果点击命中区域内部分,就执行this.PerformClick,否则不要执行,这样点击区域外的部分就不会向外抛出Click事件。

其实用Reflector看着系统内置的一些ButtonControl也就明白怎么去临摹了。