Exercise: A full menu and toolbar form

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.

The answer to the exercise will be included and explained if you attend the course listed below!

Category ==> Visual C Sharp  (65 exercises)
Topic ==> Toolbars, menus and status bars  (1 exercise)
Level ==> Average difficulty
Course ==> WinForms using Visual C#
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

The aim of this exercise is to create a form allowing you to change the colour of textboxes using either a menu, toolbar or short-cut menu:

Visual C Sharp 2010 exercise - Toolbars, menus and status bars (image 1)

What your final system should look like

First add the existing form frmNewHeart from the folder shown above into your project, then add a menu, toolbar and context menu and write the code to get them working!

Here's what the Colour menu would look like for our example (the Red option is disabled and checked, as this is the colour selected):

Visual C Sharp 2010 exercise - Toolbars, menus and status bars (image 2)

The other colours should work in a similar way

You may find the following property useful to write (it will allow you to return the currently selected textbox (that if the user is not on a text box, this routine will return null - which you can test for):

Visual C Sharp 2010 exercise - Toolbars, menus and status bars (image 3)

This property will return the currently selected textbox

When everything's working OK, close the form down!

This page has 0 threads Add post