To Jost .NDP Site

Windows Forms-1 Notes

Review Questions

  1. If your .Net solution has more than one Main method, how does the CLR know which one to use?

  2. What do these symbols mean in C#? Some have more than one meaning.
    +   &   /   %   ^   #   @   ( )   { }   [ ]

  3. What are the values of these expressions?
    "1" + 2 + 3     18 / 4 * 2.0

  4. What does 328.76M mean?

  5. Which operators use short circuit evaluation?

  6. How do you know if & denotes logical or bitwise and?

  7. Give four ways to declare and initialize a one-dimensional array of five zeros.

  8. For what are base 64 strings used?

  9. Why are the enumerations important?

  10. What does "{3,8:#.00}" mean as a format string?

  11. Give three methods in which a format string can be used.

 

Examples

FutureValue1  DragDrop  KeyPress  Cascade  TextChanged1  TrackBar  PictureBox  FutureValue2  TextChanged2  ThreeState  Beverage  Panel  ListBox  CheckedListBox  ComboBox  ImageList
 
Example files: winforms1.zip and winforms1.txt.

 

Part A:   The System.Windows.Forms.Control Class.

  1. Controls as Classes   Intro.Controls Example

  2. Form Instantiation

  3. Event Handlers

  4. The Control Class.

  5. Additional Comment about Controls

 

Part B: Some Important Controls

  1. Label

  2. Button

  3. TextBox   KeyPress, Cascade and TextChanged1 Examples

  4. TrackBar   TrackBar Example

  5. PictureBox   PictureBox Example

  6. ErrorProvider   FutureValue2 and TextChanged2 Examples

  7. CheckBox   ThreeState Example

  8. RadioButton

  9. GroupBox   Beverage Example

  10. Panel   Panel Example

 

Part C:   Message Boxes and Input Boxes

  1. Syntax:   MessageBox.Show("Message")

 

Part D: More Controls

  1. ListBox   ListBox Example

    • Properties: Items, Text, SelectedIndex, SelectedItem, SelectionMode, SelectedIndices, SelectedItems, Sorted

    • Methods:   Items.Add, Items.Remove, ClearSelected, SetSelected, GetSelected

    • Events:   Click, DoubleClick, SelectedIndexChanged

  2. CheckedListBox   CheckedListBox Example

    • Properties:   CheckedIndices, CheckedItems, CheckOnClick, ThreeDBoxes

    • Methods:   GetItemChecked, SetItemChecked

    • Event:   ItemCheck

  3. ComboBox   ComboBox Example

    • Properties: Items, Text, SelectedIndex, SelectedItem, SelectedText, SelectionStart, SelectionLength, DropDownStyle

    • Methods:   Same as ListBox.

    • Events:   Same as ListBox.

  4. ImageList   ImageList Example

    • An ImageList control is for storing images in memory to be used in other controls.

    • Obtaining images from an ImageList is more efficient than loading images from disk every time they are needed.

    • The largest image that can be stored in an ImageList control is 256 x 256 pixels.

    • All of the images in an ImageList control must be the same size.

    • Properties:   ImageSize, ColorDepth, Images

    • Method:   Images.Add

 

Part E: CommonDialog Classes

  1. The CommonDialog Class

    • Methods   Reset, ShowDialog, ShowHelp

    • Events   HelpRequest

  2. The FileDialog Class (Derived from CommonDialog)

    • Methods   AddExtension, CheckFileExists, CheckPathExists, DefaultExt, DeReferenceLinks, FileName, FileNames, Filter, FilterIndex, InitialDirectory, RestoreDirectory, ShowHelp, Title, ValidateNames

    • Methods   Reset

    • Events   FileOk

  3. The OpenFileDialog Control (Derived from FileDialog)   WinForms2.FileDialog Example

    • Properties   MultiSelect, ReadOnlyChecked, ShowReadOnly

    • Methods   OpenFile

  4. The SaveFileDialog Control (Derived from FileDialog)

    • Properties   MultiSelect, ReadOnlyChecked, ShowReadOnly

    • Methods   OpenFile, CreatePrompt, OverwritePrompt

  5. The ColorDialog Control (Derived from CommonDialog)   WinForms2.ColorDialog Example

    • Properties   AllowFullOpen, AnyColor, Color, CustomColors, FullOpen, ShowHelp, SolidColorOnly

    • Methods   Reset