9.13. Create a Form That Cannot Be Moved

Problem

You want to create a form that occupies a fixed location on the screen and cannot be moved.

Solution

Make a borderless form by setting the FormBorderStyle property of the Form class to the value FormBorderStyle.None.

How It Works

You can create a borderless form by setting the FormBorderStyle property of a Form to None. Borderless forms cannot be moved. However, as their name implies, they also lack any kind of border. If you want a border, you will need to add it yourself, either by writing manual drawing code or by using a background image.

One other approach to creating an immovable form does provide a basic control-style border. First, set the ControlBox, MinimizeBox, and MaximizeBox properties ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.