6.14 Create a Form That Can t Be Moved


6.14 Create a Form That Can't Be Moved

Problem

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

Solution

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

Discussion

You can create a borderless form by setting the FormBorderStyle property to None . Borderless forms can't 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's one other approach to creating an immovable form that provides a basic control-style border. First, set the ControlBox , MinimizeBox , and MaximizeBox properties of the form to false . Then set the Text property to an empty string. The form will have a raised gray border or black line (depending on the FormBorderStyle option you use), similar to a button. Figure 6.8 shows both types of immovable forms.

click to expand
Figure 6.8: Two types of forms that can't be moved.



C# Programmer[ap]s Cookbook
C# Programmer[ap]s Cookbook
ISBN: 735619301
EAN: N/A
Year: 2006
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net