How To Add A Drop Shadow Effect On A VB.NET Winform With Its Form Border Style Property Set To None.
When developing apps using VB.NET in visual studio creating a user interface is one of the easiest things to do. There are also third party VB.NET ui frameworks that you can use if you wish to come up with a more custom and modern user interface. By default all windows forms have a drop shadow effect and is very usefull if the VB.NET application has multiple winforms. However when using a custom VB.NET UI framework or if you set the form border style property to none, the drop shadow effect is lost. This tutorial provides a guide on how to add a drop shadow effect on a VB.NET Winform with its form border style property set to none. Click on the button below to watch the video
In order to complete this tutorial successfully the following items are required. Please ensure to have these items available before taking implementation action on this tutorial:
1) A desktop or laptop running windows 7, 8 or 10
2) Atleast 4gb worth of physical memory (RAM)
3) Visual studio 2010 or newer
4) Basic understanding on how to create visual basic applications
1) Open visual studio and create a new project
2) set the form border style property to none
3) Write code to add a drop shadow effect on the winform
4) Run the project to test changes.
1) In this tutorial Visual Studio Ultimate 2013 is used. Open the VS 2013 IDE and click on FILE > NEW > PROJECT or use the keyboard shortcut “CNTRL + SHIFT + N”
On the NEW PROJECT creation dialogue, select VISUAL BASIC, choose WINDOWS FORMS APPLICATION and type in a name for the project on the NAME text box.
Click on OK to proceed.
2) In the Visual Basic designer, click on the windows form and on the PROPERTIES pane set FormBorderStyle to none and the blue border and form controls on the windows form will disappear.
3) If you run the program, notice how the winform does not have the drop shadow effect. If the application has multiple windows forms it might end up being a bit difficult for end users to distiguish the winforms.
4) Double click on the windows form and type in the following code:
Define the CS_DROPSHADOW constant
Private Const CS_DROPSHADOW As Integer = 131072
‘ Override the CreateParams property
Protected Overrides ReadOnly Property CreateParams()
Dim cp As CreateParams = MyBase.CreateParams
cp.ClassStyle = cp.ClassStyle Or CS_DROPSHADOW
5) Save the changes , and click on the START button on the tool bar so as to test out the code. You should notice a drop shadown effect on the Windows Form.