设置Region属性:
创新互联建站是一家以成都网站建设、网页设计、品牌设计、软件运维、成都网站推广、小程序App开发等移动开发为一体互联网公司。已累计为成都生料搅拌车等众行业中小客户提供优质的互联网建站和软件开发服务。
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddEllipse(0, 0, 400, 300)
Region = New Region(path)
没听说过这种按钮能变椭圆的。但是你可以用图片按钮实现这种效果,即用图片或者Flash作为按钮,加上点击事件就行了。
新建一个Winform,拖两个图片框。图片框1在设计器中选择一个图片(尺寸在图片框容纳为佳)。如下代码测试通过:
private void button1_Click(object sender, EventArgs e)
{
Image img1 = this.pictureBox1.Image;
Image img2 = CropToCircle(img1);
this.pictureBox2.Image = img2;
}
public Image CropToCircle(Image img1)
{
Image img2 = new Bitmap(img1.Width, img1.Height,
img1.PixelFormat);
Graphics g = Graphics.FromImage(img2);
using (Brush br =
new SolidBrush(SystemColors.Control))//背景色
{
g.FillRectangle(br, 0, 0,
img2.Width, img2.Height);
}
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, img2.Width, img2.Height);
g.SetClip(path);
g.DrawImage(img1, 0, 0);
return img2;
}
'我给你找到了,设置region属性就可
Private Sub PictureBox1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles PictureBox1.DoubleClick
If PictureBox1.Region Is Nothing Then
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddEllipse(0, 0, 200, 200)
PictureBox1.Region = New Region(path)
Else
PictureBox1.Region = Nothing
End If
End Sub
'这个双击图片框使其变形,通过GraphicsPath对象可以作出各种形态来,比如可作出文字形状
Dim stringText As String = "我是谁"
Dim family As New FontFamily("Arial")
Dim myfontStyle As Integer = CInt(FontStyle.Italic)
Dim emSize As Integer = 86
Dim origin As New Point(20, 20)
Dim format As StringFormat = StringFormat.GenericDefault
path.AddString(stringText, family, myfontStyle, emSize, _
origin, format)
PictureBox1.Region = New Region(path)
记得VB6当中有Shape控件,但是VB.net里这个控件不存在了。
提个思路:使用Picture控件或Label控件,通过代码在控件里绘图想要的图形,可以试试。
VB.NET没用过
VB6的话用form.circle方法画圆,圆的半径和圆点用form.width或者form.height乘以比例数来得到,然后在form_resize事件中重画圆就可以了
不知道和VB.NET差别大不大