Creating a VB.NET form that users cannot move
Takeaway: In Visual Basic .NET, there are two simple options for making sure that a form you create cannot be moved by users. Irina Medvinskaya discusses both options in this tip.
There are situations that require developers to prohibit users for moving a particular form. This may be required whenever you feel that the users need to fill out some data before proceeding or moving the form to work with some other application form.
In VB.NET, there are two simple options for making sure that the form can't be moved. In this tip, I explore both options, which are creating a borderless form and creating a form with borders.
Borderless form
You can make a borderless form by setting its FormBorderStyle property to None. This method works because borderless forms can't be moved. However, this option is somewhat limiting since utilizing this method results in a form that doesn't have any borders. The form would look like Figure 1.
Form with borders
If you want to implement a form that has borders but cannot be moved by users, the alternative is to set the ControlBox, MinimizeBox, and MaximizeBox properties to False. Then, you would set the Text property to an empty string. The resulting form will have a raised border but will not be moveable. The form would look like Figure 2.
Miss a tip?
Check out the Visual Basic archive, and catch up on the most recent editions of Irina Medvinskaya's column.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
SponsoredWhite Papers, Webcasts, and Downloads
- Watts and Volt-Amps: Powerful Confusion American Power Conversion (APC)
- MIT Podcast: How Enterprise Software Drives Higher Productivity Efficiency SAP
- Seeing the Big Picture: A Corporate Guide to Better Decisions through IT SAP
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET


Harnessing the power of waves
Planting solar gardens
Fill your car for $1.10 a gallon?
