Changes

Jump to: navigation, search

C Sharp and Windows Forms

1 byte removed, 19:14, 1 April 2009
no edit summary
== Creating a New Form ==
Throughout this chapter we will work with a form in a new project. Begin by starting Visual Studio and creating a new Windows Application project and name . Name the project ''CSharpforms''.
Once the new project is created you will see a new Form in Visual Studio ready for you to begin work.
All GUI objects in a C# application need a name so that they can be referenced in the C# code. When a new object is added to an application in Visual Studio it is assigned a default name which usually consists of the object type and a number. For example the first form object in an application is named ''Form1'', the second ''Form2'', and so on.
To change the name of a Form to something more meaningful , simply click in any area of the Form in Visual Studio and change the ''(Name)'' value in the ''Properties'' panel.
== Changing the Form Title ==
Click on the ''Local Resource'' option button and click on ''Import'' to browse for an image. If you don't have any images of your own readily available try looking in for the ''Sample Pictures'' folder in ''My Documents''.
Once selected , the image will be applied to the form background and any controls added will appear on top of the image. The following figure shows a form with a background image and a Button control:
[[Image:c_sharp_form_background_image.jpg|A Visual Studio Form with a custom background image]]
== Changing the Form Border ==
By default a form can be resized by the user. Visual Studio allows both is the behavior, and the appearance of the border to be controlled by manipulating the ''FormBorderStyle'' property. The border may be configured to allow, or disallow resizing of the form, with a variety of border styles (such as 3D).
To change the border, select the ''FormBorderStyle'' in the ''Properties'' panel of the form you which wish to modify. Click on the down arrow in the value field to drop down a menu of items and select the setting of your choice. Feel free to experiment with the different settings, using the '''F5''' key to build and run your application to try out each setting.
== Stopping a Form from Appearing the Windows Taskbar ==

Navigation menu