Create a Form That Can’t 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 FormBorderStyle to None.

Discussion

You can create a borderless form by setting the FormBorderStyle property to None. Borderless forms cannot be moved. However, they also lack any kind of border—if you want the customary blue border, you’ll need to add it yourself either with manual drawing code or by using a background image.

There is one other approach to creating an immovable form that provides a basic control-style border. First, set the ControlBox, MinimizeBox, and MaximizeBox properties to False. Then, set the Text property to an empty string. The form will have a raised ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.