|
Broken links? Email us! |
|
Hi there! Its time to do what? To play Columbus! Of course not all set to go rediscover America but at least to discover the new enhanced User Interface capabilities of the .Net platform! In this lab we'll be looking at various new UI features such as Transparent Windows, Control Anchoring and Control Docking. The jargon getting to you? Fret not at the end of this lab exercise not only will you be able to understand what these mean but also be able to create WinForm applications which use them.
So lets start the journey by starting the Visual Studio.net IDE (if its not already running)
This is how a TrackBar control looks in the ToolBox
Click on the Left side button on the grid.
Why did we do that?
What we've just done is that we've ‘docked' the TrackBar control to the left side of the screen. Now the TaskBar control is ‘tied' or rather ‘is glued' to the left side of the screen, if you notice in the designer the control is already stuck on to the left side of the screen. Even if you at runtime maximize the screen it doesn't budge! It stays right there! We'll see this in action soon.
Property |
Set To |
Large Change |
5 |
Maximum |
100 |
Minimum |
10 |
Small Change |
5 |
Value |
100 |
This is how a Label control looks on the ToolBox
Your Form should now look like this
This is how a Button control looks on the ToolBox
Change the Text property of the button control
Anchor property of the Button
Why did we do that?
The Anchor property of any control when set ‘anchors' the control to that position on the Form. That means even if the user resizes the form the control automatically resizes and repositions itself to fit onto the new form size. When a control is anchored to a form and the form is resized, the control maintains the distance between the control and the anchor positions. In our lab, you have a Button control that is anchored to the top, left, right, and bottom edges of the form, as the form is resized, the Textbox control resizes horizontally so that it matches the same distance from the right and left sides of the form. In addition, the control positions itself vertically so that its location is always the same distance from the top and bottom edge of the form. If a control is not anchored and the form is resized, the position of the control relative to the edges of the form is changed.
Your form should now look like this
Form1.Opacity = (TrackBar1.Value) / 100
Type in the above line of code into the code window
Why did we do that?
To explore Transparent Windows! To make a window transparent we need to set its opacity property, 1 means its completely opaque( not transparent), the kind of windows we are used to see. And 0 meaning that the window is completely transparent ( infact invisible!). we will be able to adjust the transparency of our form using the TrackBar ! Push it up towards Full Visibility to make it completely opaque, push it right down to make it almost completely transparent! We will see this in action next.
Click on the view designer button
MessageBox.Show ( "You cant get rid of me that easily!");
Your very own ghostly window!
Hope you guyz had fun [I know you learnt nothing worthwhile!] but in any case if you think you have and there is anything more that you would like to know or would like to flog me about some dumb mistake I made please do so at mjeelani@yahoo.com