Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Visual C# (55 exercises) |
Topic ==> | Inheritance (5 exercises) |
Level ==> | Relatively easy |
Subject ==> | C# training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Suppose that whenever you create a form, you always set values for certain properties as follows:
Property | Value |
---|---|
StartPosition | System.Windows.Forms.FormStartPosition.CenterScreen |
FormBorderStyle | FormBorderStyle.FixedDialog |
Text | You set the caption of the form when you first create it. |
Height | 120, 300 or 500, depending on whether the form is tidgy, mediumish or huge. |
Width | 200, 400 or 700, depending on whether the form is tidgy, mediumish or huge. |
What you'd like to be able to do is to write code like the following:
// create a new template form, setting its caption
FormTemplate ft = new FormTemplate("Wise Owl");
ft.size = FormTemplate.FormSize.Tidgy;
ft.Show();
When you attach this code to a form button and run it, you'd like it to create and show a form on screen:
Clicking on a button in a test form should run this code to display a new form, with the caption, properties and size requested.
To get started, create a new class called FormTemplate, which should include an enumeration to determine the form size:
public enum FormSize
{
Tidgy,
Mediumish,
Huge
}
Your class will need to use the System.Windows.Forms namespace, and should inherit the Form class (so that it will behave like a form, with knobs on).
Add a constructor to your form which takes the form caption as an argument, and within this constructor set the start position, border style and caption.
Add a write-only property called Size which sets the dimensions of the form according to the value of the FormSize enumeration set.
Create the code shown at the start of this exercise to test out your class; running it should bring a form up on screen of the required size and with the required behaviour!
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.