A perfect application is one that eases the work of the user and also pleases the user’s eyes. Given below are some effects provided by Winforms that help enhance the visual effect of an application. 1] Transparent Forms 2] Control Anchoring and Docking 3] Visual Inheritance 1] Transparent Forms By adjusting the value of the Opacity property of the form, the level of transparency of the form can be changed. The Opacity property can be set either at the time of designing, using the Properties window, or at runtime. It can take a value between 0.0, which indicates complete transparency to 1.0 which indicates complete opacity. Examples, denotes the code to make a form transparent. Example, Me. Opacity = 0.83 Or Formname.Opacity = 0.83 2] Control Anchoring and Docking When a form is resized the controls on the form do not change their position; they maintain the position that they were originally placed in. So it the form is maximized, the distance of the control from some of the borders of the form changes. The Anchor property of a control allows us to set one or more borders of a control to remain at a fixed distance from the borders of the form. The Anchor property specifies which borders are to be controlled this way. For example, suppose we have a form with a textbox. We would like the textbox to stay at the same distance from top, left and right borders of the form. To do that we would need to set the Anchor property for the textbox to TopLeftRight in the properties window. To set the Anchor property for the textbox control, we need to click on the cross and select the Top, Left and Right bars. A control can also be docked to a single or all the edges of a form. A control that is docked to a particular edge of a form does not move from that edge when the form is resized. On resizing a form, the docked control’s size changes according to the size of the edge of the form. For example, suppose we would like the textbox control to stay at the top and not be moved to any other place when the form is resized, then we can dock the control to the edge of the form. The difference between anchoring and docking is that anchoring is with respect to the position of the control on the form, that is its x, y coordinate value, but docking is with respect to the entire edge of the form. If more than one control is docked to an edge they are ‘not’ placed on top of each other. To dock a control to a form edge, set the Dock property of the control. The dock property takes any one of the Dock Style options whose default is “none”. 3] Visual Inheritance Inheritance saves the programmer from the trouble of re-typing codes and provides the luxury of code reusability. Similarly it goes without saying that it would save the programmer a lot of time if it was possible to inherit user interface as well. Winforms supports inheritance of user interfaces. A form that is going to be inherited from is called the base form. The form that inherits from the base form that is going to be inherited from is called the base form. The forms that inherit from the base form contain the controls and functionality of the base form. In addition these inherited forms can contain their own controls and functionality.

Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments