Changes

Jump to: navigation, search

Visual Basic and Forms

10 bytes added, 20:33, 8 April 2009
no edit summary
All objects in a Visual Basic application need a name so that they can be referenced in the 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 ==
* Color by name - Simply type in a color name into the ''BackColor'' value field (for example ''Red'', ''Yellow'', ''Cyan'' etc).
* Color by RGB value - Colors may be specified by entering the hexadecimal RGB values (for example #FFFFFF for white, #000000 for while black and so on). RGB values may also be specified using decimal values (for example 255,255,255 for white, 0,0,0 for black etc).
* Color from existing palette - Clicking on the down arrow in the ''BackColor'' value field will display a drop down menu. Lists are available for web safe colors, custom colors and system colors.
Once you have selected a new color the background color of your form will change to reflect the new setting.
== Changing The the Form Background Image ==
In addition to changing the background color of a form, it is also possible to specify a background image. This is specified using the form's ''BackgroundImage'' property in the ''Properties'' panel. When the ''BackgroundImage'' property is selected in the Property panel a button containing the label '...' appears. Click on this button to display the ''Select Resource'' window:
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:visual_basic_form_background_image.jpg]]
Each window in a Windows application has, by default, Minimize, Maximize and Close buttons in the top left hand corner of the title bar. In addition, clicking on the icon on the right hand side of the title bar drops down a control box containing the same options, plus options to resize the window.
These options make it easy for the user to perform tasks such as minimizing or maximizing a form. If, however, you do not want these controls to be available for a particular form they can be disabled from the ''Properties'' panel for the form in question. To disable the Maximize button set the ''MaximizeBox'' property to ''False''. Similarly, disable the ''Minimize'' button by setting the ''MinimizeBox'' property to ''False''. In each case the button will still be visible, but will be disabled so the user cannot click on it.
To remove all controls, including the Control Box and the Minimize, Maximize and Close buttons set the ''ControlBox'' property to false''False''. When set, the only content in the form's toolbar will be the form title.
== Setting Minimum and Maximum Form Sizes ==
== Changing the Form Border ==
By default a form can be resized by the user. Visual Studio allows both is this 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 ==
== Creating a Transparent Form ==
The ''Opacity'' property can be used to control the degree of transparency of a form of control. The lower the opacity percentage, the more transparent the form or control. To make a form transparent, select the form and change the ''Opacity'' percentage to 70% (if you select a percentage that is too low the form will be invisible when the application is run). Press '''F5''' to build and run the application. The form will be partially transparent in that you can still see the form and its controls, but you can also see what is on the desktop behind the form.

Navigation menu