Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to make a Round Shape Form

Author: DevASP
Download Source Code :

This article is about, how you can make your Form Circular/Round and how to control its Transparency.

  • Steps you will do.
  • Start visual studio and create a new window application.
  • Set the following properties of the Form.


Name = frmMain, Text = Opacity & Circular

  • Drop a label control and set its following properties.


Name = lbMessege, Text = Drag to change opacity, TextAlign = MiddleCent


  • Drop a Horizontal Scroll Bar Control on your form and set its following properties.


Name = HSB, Cursor = Hand, Minimum = 1, Maximum = 100, Value = 100


  • Drop a button on the form and set the following properties.


Name = btChange, Text = Change Shape

  • Declare the two Boolean type variables as below in your code window.

Private warningopacity As Boolean

Private surfaceround As Boolean


  • In the load event of the form set these variables to true.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


  warningopacity = True

  surfaceround = False


End Sub


  • Write the following code in the scroll event of the horizontal scroll bar.

Private Sub HSB_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HSB.Scroll


Me.Opacity = HSB.Value / 90


If HSB.Value <= 30 And_


warningopacity = True Then


MessageBox.Show("WARNING: The form will not be visible if the opacity is set to minimum.  The scrollbar will not be visible.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)


warningopacity = False


ElseIf HSB.Value > 30 Then


   warningopacity = True


End If


End Sub


And finally write the following code in the click event of the button to change the shape from rectangle to round or reverse of this.


Private Sub btChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btChange.Click


If surfaceround = False Then


surfaceround = True

btChange.Text = "Click to return to a default window"


Dim gpath As New Drawing2D.GraphicsPath


gpath.AddEllipse(New Rectangle(0, 0, Me.Width, Me.Height))


Me.Region = New Region(gpath)




ElseIf surfaceround = True Then


 surfaceround = False

 btChange.Text = "Click here to turn the window into a circle"


Me.Region = New Region



End If


End Sub

Article Comments
This is a very usefull site

Posted on 2/24/2007 10:59:05 AM by Noushad

That's gr8 help to all of us

Posted on 3/27/2007 2:03:21 PM by Hitesh

this is very usefull in some other case

Posted on 7/18/2007 4:35:25 AM by Suyog

Add Article Comment:
Name :
Email Address :
Comments :
<< Detect for multiple values in a ComboBox.

Disclaimer - Privacy
© 2002-2018