Monday, March 28, 2005

VB.NET region code

This simple snippet shows how to create an oval button using paint event

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rgn As Region
Dim Pth As New System.Drawing.Drawing2D.GraphicsPath
Button1.BackColor = Color.Red 'so you can see the shape better!
Pth.AddEllipse(New Rectangle(0, 0, Button1.Width, Button1.Height))
rgn = New Region(Pth)
Button1.Region = rgn
Pth.Dispose()
rgn.Dispose()
End Sub

No comments:

Post a Comment