CIS206 - Advanced Visual Basic - Week 2

Controls and Printing


Week 2 completes the review of the prerequisite material with the exception of classes.

Five examples for tonight

The last example was to be the assignment, but we will walk through this as part of the lab

There is some new material here though


Example 1

Reviews the mechanics of invoking a second form. We deal only with ShowDialog method, which means that the 'Child' forms keeps control until it returns back to the 'Parent' 

This example also details how to trace through events using Debug.Writeline. This will be helpful in tracing the events fired in future programs.

Download the Example


Example 2

MDI (Multiple Document Interface) forms are probably new to most in the class and we will spend just a brief amount of time reviewing the basics. The Menu control will be a review.

Built In 'Most Recently Used' window list and Cascade / Tiling options are also part of the MDI.

Cut | Copy | Paste which makes use of the Clipboard object are reviewed.

Download the Example


Example 3

Color Dialog and Font Dialog controls are part of the set of Common Dialogs. The initialization of properties and restricting user access to certain dialog options and selections is demonstrated in this example.

Download the Example


Example 4

The implementation of Drag and Drop and Control Arrays will use the AddHandler function to link the Controls with their respective event handlers. 

Drag and Drop is implemented in two steps and depending on the application being developed, the programming can implement making the object a Drag Source, a Drop Target, or both.  

As all controls are objects, any control can be created at any time with the program code. This was demonstrated while creating an instance of a form in prior examples. This example creates 26 instances of a Button, and the uses AddHandler to point to the appropriate event handlers that are not associated with objects at design time. Also demonstrated is the ability to invoke multiple event handlers as part of a single event.

Download the Example


Assignment

No assignment for this week other that to make sure that you have a solid foundation on the prerequisite material. Next week we move into building classes and instances of our own objects as opposed to the objects delivered with the .Net Framework. Review the examples from today and week one.

This example ties together most of the concepts from the first four examples and introduces Document and Print Preview  controls.

This example accepts a Name, Rate of Pay, and Hours Worked and stores these values and the calculated Gross Pay in a ListBox control. The 'Calculate' button is disabled until all fields are entered and in the proper format. A tab delimited string is built and stored in the ListBox. Double clicking on the ListBox item will summarize the item on a dialog form. Any of the main form variables can be enter using the keyboard, pasted from the clipboard, or dropped from a drag operation. Selecting File and Print Preview will generate a report. This process handles multiple pages and right justifies the numeric values so that the decimal points are aligned. Help | About will display a modal form that is part of the project.

Download the completed assignment


Return to Home Page