CSCI E-143 CertPrep: Controls
(Kalani, chapter 2)
Saturday, Oct. 16, 2004
This Saturday we will cover Kalani's chapter 2, "Controls".
You will find that this is a long chapter.
Here are some things in Kalani that you should know.
(The order they are listed in is that of Kalani's chapter 2).
- Properties of controls:
- If you add a Control through code, you must add it to its container's
list of Controls, or it won't be displayed
- The Anchor
and Dock settings
- The difference between them
- The default for Anchor is
top,left
- The default for Dock is
none
- You should also know the meaning of
Fill for Dock
- The difference between the Hidden and the
Disabled properties
- The effect of the Visible property
on shortcuts
- Tab indexing, Tab stopping, and setting the order of tabs.
- Distinguish these from the TabControl,
described below
- The Text property:
- How you use an ampersand (&) in the Text
control to get to that control with the "Alt" key
- What do you do if the underscore doesn't appear, as it's supposed to
if you use the ampersand in a Text?
- How to get to, say, a TextBox,
by using an ampersand in a Label control
just previous to the TextBox
in the Tab order
- Having two different buttons do the same thing for a click
by adding the same event handler to the two buttons
- What the seven Common Dialog Boxes dowhat properties you can set with
each one:
- ColorDialog, FontDialog, OpenFileDialog, PageSetUpDialog,
PrintDialog, PrintPreviewDialog, SaveFileDialog
- How to set and retrieve Results of a Dialog Box:
using, say,  DialogResult.OK
- How to handle Filters in a File Dialog, and how the indexing works for
these filtersit starts with one, not zero
- Something about the FileInfo class
- Something about setting up a custom dialog box
- Assigning DialogResult.OK
to a button
- Setting up a property for returning something set in the dialog box
- The difference between modal and non-modal dialog boxes:
- Modal boxes are shown with ShowDialog()
- Non-modal boxes are shown with Show()
but, confusingly enough
- MessageBoxes are shown modally with
MessageBox.Show()
- Specific Controls:
- Label
- How the ampersand works, remembersee "The Text Property"
in "Properties of Controls", above
- The "Important Members" of the Label Control are pretty obvious
Image, Font, Text, TextAlign
- Incidentally, you can have a
MultiLine Label
- LinkLabel
- How to set it up
- The fact that you can put two links in one
LinkLabel if you do some alignment
- The fact that you must Add the links to the Control.
(See Step by step 2.7, page 145)
- TextBox and RichTextBox
- The difference between them
- MultiLine vs.
AcceptReturn:
AcceptReturn works only if
MultiLine is set to true
- The PasswordChar property
- WordWrap vs. scroll bars
- WordWrap and
MultiLine
- Some of the members unique to
RichTextBox,
such as DetectUrls
- The additional methods available in
RichTextBox
which are not mentioned on Kalani's page 147,
but are on page 201:
Undo(); Redo(); CanUndo(); CanRedo()
- PictureBox.
A less common control. Know
- What it is
- The fact that an image renders faster if it does not have to
resize, if, for instance, you avoid
AutoResize and give a
Rectangle of specific size
- GroupBox vs.
Panel.
Know what they are, and the difference:
- GroupBox allows a caption (in the
Text property)
- Panel allows scroll bars
- Button, CheckBox, RadioButton
- Know the difference, obviously
- Know the peculiarities of the CheckBox
(and they really are peculiar):
- What the ThreeState property does
(box, page 152)
- How you can set a CheckBox
to the Indeterminate state
- Exactly how you determine whether the box is checked
(also in the box, page 152)
- What the AutoCheck property does (box, page 153)
- (For RadioButton, it would be nice to know
exactly how the CheckChanged event works,
even though Kalani doesn't talk about it.
Is the On event always second?
Or do you always have to check the setting of the button when you
get this event? And doesn't this apply equally to
Button and
CheckBox?)
- Incidentally, Kalani has an explanation on page 154 of how binary
switches work in the FontStyle
enumeration: they use the "or" operator ( | )
to set more than one switch on.
This is a valuable piece of information, which you probably
know already.
- ListBox, CheckedListBox, ComboBox.
The ListBox and
The ComboBox are important;
the CheckedListBox, less so. Know
- How to specify selection mode, including, I am afraid,
these irritating details:
- The values of the SelectionMode
enumeration as applied to a ListBox:
MultiSimple, MultiExtended, None, One
- Which of these apply to a
CheckedListBox: only
none and
one.
(Box, page 156. Well, maybe this isn't so
important.)
- How to retrieve selection(s) from these Controls
- What do you get for SelectedIndex
if nothing is selected?
- For ComboBox,
know how to specify drop-down mode
- AndI think this is really useful and important,
and not just for certificationexactly what can you put
into the Items
collection of one of these list boxes?
- DomainUpDown, NumericUpDown
- Know the difference, and the basics
- Once again, exactly what can you put into the
Item collection of a
DomainUpDown control?
- MonthCalendar, DateTimePicker.
These are less important. Know the basics.
- TreeView, ListView.
Interesting, but not very important for certification.
Know what they are, and the basics, including
- The TreeView control's
default event, AfterSelect,
and what it gives you
- What common Windows application illustrates both of these
Controls perfectly?
- Timer, TrackBar, ProgressBar.
Again, interesting,
but not very important for certification.
Know what they are, and the basics.
- Know which class of Timer to use:
System.Windows.Form.Timer,
not System.Timers.Timer.
(Box, page 177.)
Who would have thought it?
- What is unusualperhaps uniqueabout the
Enabled property of the Timer control?
- HScrollBar, VScrollBar.
Once again, interesting,
but not very important for certification.
Know what they are, and the basics.
- TabControl.
I think this Control is quite interesting,
but I have to admit it's not very important for certification.
Know what it is, and the basics.
Menus. These are important.
You really should look at the long example starting on page 190.
And you must know the basics and the events, including
- MenuItem vs.
MainMenu
- What can you put into the MenuItems collection?
- How to attach an event to a MenuItem
- The difference between Hidden and
Disabled for menu items and shortcuts
- Notice the unfortunate glitch in the
RadioCheck feature described in the box
atop page 197.
- The use of the Popup event for
menuswhen it occurs, and what you use it for:
- The Popup event occurs just
before the menu is displayed
- You can use it to enforce the settings for
RadioCheck menu entries,
whose mutually exclusive settings are not done automatically
by the system
- ContextMenu
- What it is, of course
- How it differs from the other menus
- How to set one up
- How you associate a particular context menu with a particular
control: the control's
ContextMenu property
StatusBar. This is the banner at
the bottom of the window.
- Know how to set it up
- Remember to use "Send to back" when setting it up
- Know something about individual panels
- How do you size these panels?
- What is the AutoSize property?
ToolBar
- Know how to set one up.
- Remember to use "Send to back" when setting it up
- Be aware that you only get one kind of
ButtonClick event
for the whole tool baryou don't get a separate event for
each item on the ToolBar.
(This is a good example of Kalani's giving you standard code for solving
a problem.)
The questions to be answered are
- How do you know which ToolBar item was selected?
- How do you associate a MenuItem with an element
on a ToolBar?
- How do you generate a Click event
for the associated MenuItem?
- What is the effect of disabling the
MenuItem
associated with a tool bar button?
MDI ("Multi-Document Interface") and Child menus:
I think this subject is less important,
but since your luck on the exam might vary, you should know things like
- How parent and children windows are denoted:
- the IsMdiContainer
property on the parent
- the MdiParent
property on the child
- How to copy parts of child menus to other menus.
There are some really picky details here,  which just might
show up on an exam.
- The MdiList property of a
MenuItem displays a list of the child menus
ToolTips. Pretty simple.
They are covered in the example at the end of the chapter,
on page 218. Know
- What they are
- How you add them to a control: you have to add the
ToolTip component to the form.
Only then will you be able to set the individual
ToolTip
property to each Control on that form.
Well, I said it was a long chapter.
I am afraid you will have to use your judgement as to which of the later and
more rarely used controls and their features are important enough
to remember.
You might see several of them on an exam; then again,
you might not see any of them. I don't remember that I did.
See you Saturday.
Among the sample test questions at the end of Chapter 2 in the
"short Kalani" book,
I am very unhappy with the answer to question 9 (page 69),
which says that a z-order number with the lowest value describes the window
appearing on top.
First, I think this is wrong; I think the highest z-order appears
on top.
Second, z-order seems completely unimportant in .NET.
Of the dozen-odd textbooks I checked on this issue, not one had an index entry
for "z-order".
And the on-line .NET documentation explains z-order only for Windows CE.
Here are the relevant questions from the two tests at the end
of short Kalani:
Test 1: questions
24 (page 366; answer: page 393),
26, 27.
Test 2: questions
16 (page 411; answer: page 442),
17, 22.
(Some of these questions may duplicate those in long Kalani.
Both texts are listed
here.)
Last revised Oct. 17, 2004