Appendix V. Index of Examples

This book includes more than 400 example programs that are available for download from the book's web site. This appendix briefly describes the examples in each chapter so you know which programs to look at for a particular topic.

Most of the chapters include example applications, so the following list includes entries for every chapter. Only Appendixes A, G, and K have examples, so only they are listed here (although many of the chapters have examples covering material in the other appendixes).

  • Chapter 1

    • There are no example programs for this chapter.

  • Chapter 2

    • There are no example programs for this chapter.

  • Chapter 3

    • There are no example programs for this chapter.

  • Chapter 4

    • There are no example programs for this chapter.

  • Chapter 5

    • There are no example programs for this chapter.

  • Chapter 6

    • Fibonacci — Calculates Fibonacci numbers. [page 82]

  • Chapter 7

    • There are no example programs for this chapter.

  • Chapter 8

    • EmployeePropertyGrid — Displays information about an object in a PropertyGrid control. [page 109]

    • LayoutPanels — Demonstrates the Panel and TableLayoutPanel controls. [page 105]

    • UseDialogs — Demonstrates the ColorDialog, FolderBrowserDialog, FontDialog, OpenFileDialog, PageSetupDialog, PrintDialog, PrintPreviewDialog, and SaveFileDialog components. [page 113]

    • UseSplitContainer — Demonstrates the SplitContainer control. [page 107]

    • UseSplitter — Demonstrates the Splitter control, which requires the use of Dock properties and stacking order so it's harder than using a SplitContainer. [page 107]

    • UseToolStripContainer — Demonstrates the ToolStripContainer. Contains two ToolStrip controls that you can dock to the ToolStripContainer's edges. [page 104]

  • Chapter 9

    • AnchorButton — Anchors a button at runtime to the form's lower-right corner. [page 131]

    • ButtonContainers — Moving buttons in and out of containers at design time.

    • CenteredButtons — Contains three buttons with Anchor=Bottom. When you resize the form, the buttons remain centered as a group.

    • Components — Screen shot of components. [page 118]

    • CustomerDialog — Uses Anchor properties to make text fields resize horizontally when the form gets wider.

    • CustomerOrders — Uses Anchor properties to make a list grow to use available vertical space.

    • DisplayRectangles — Shows a GroupBox's DisplayRectangle and ClientRectangle.

    • DivideForm — Divides a form vertically between two text boxes. [page 132]

    • Docking — Demonstrates Dock properties. [page 132]

    • FiveDigits — Demonstrates a Validating event that requires the user to immediately fix problems. [page 140]

    • FiveDigitsDeferred — Demonstrates a Validating event that flags invalid data but allows the user to leave the invalid field and fix it later. [page 142]

    • FiveDigitsSeparate — Demonstrates a Validating event that flags invalid fields and a Validated event that clears errors on valid fields. [page 141]

    • GroupBoxPreferredSize — Demonstrates the GroupBox's PreferredSize method.

    • ImageTabs — Demonstrates a TabControl that displays images on its tabs. [page 127]

    • ItemsAndSubitems — Uses design-time collection editors to edit the ListView control's Items and their SubItems.

    • MakeButtons — Shows how to add and remove controls at runtime. Also used for screen shots of the Properties window. [page 122]

    • Margins — Demonstrates Padding and Margin properties for buttons inside FlowLayoutPanels.

    • ScrolledWindow — Demonstrates the Panel control's AutoScroll property.

    • SwitchEventHandlers — Shows how to add and remove event handlers at runtime. [page 138]

    • UseSplitter — Demonstrates a Splitter.

  • Chapter 10

    • AppIcon — Uses an application icon. [page 154]

    • ChangeFormFont — Sets the form's font at runtime. [page 156]

    • CoverAll — Covers the screen with a form that has Opacity=2%. [page 147]

    • CustomDialog — Demonstrates a custom dialog that returns a dialog result. [page 167]

    • Fixed AspectRatio — Overrides WndProc and ensures that the form's width-to-height ratio remains unchanged. [page 156]

    • GhostForm — Contains a form with TransparencyKey equal to its BackColor so the form's surface is invisible. [page 148]

    • Hole — Draws a shaped form that shows only text and an ellipse. [page 148]

    • HollowSmiley — Draws a shaped form with hollow eyes. [page 148]

    • MDIEdit — Opens files in MDI child windows. This program has some limited file saving capabilities. [page 160]

    • MDIEdit2 — Demonstrates a way to let MDI children control their own loading and saving on close. This is a seriously incomplete program. [page 163]

    • MruList — Demonstrates a simple MRU list class. [page 166]

    • NoContextMenu — Overrides WndProc for a text box control and ignores WM_CONTEXTMENU messages. [page 158]

    • SDIEdit — Opens files in separate forms. This program does not save modified files. [page 158]

    • SemiTransparent — Shows a form with Opacity=66%. [page 146]

    • ShowCursors — Displays the standard cursors. [page 151]

    • SmileCursor — Displays a custom mouse cursor. [page 152]

    • Smiley — Draws a shaped form. [page 148]

    • SplashScreen — Displays a form as a splash screen or as an About dialog. [page 150]

    • TestOpacities — Displays forms with Opacity values 25, 45, 65, and 85.

    • TransparentForm — Draws a transparent form so only its controls are visible. [page 147]

    • UseMultipleWaitCursors — When you click its button, displays wait cursors on all of its forms. [page 152]

    • UseNotifyIcon — Demonstrates the NotifyIcon control. [page 154]

    • UseWaitCursor — When you click its button, displays a wait cursor. [page 151]

    • ViewWindowsMessages — Overrides WndProc and displays information about the messages the form receives. [page 157]

    • Wizard1 — Shows a particular style of wizard. This program is really intended to show the style, not implement it. [page 169]

    • Wizard2 — Shows a second style of wizard. This program is really intended to show the style, not implement it. [page 169]

  • Chapter 11

    • DrawingShapes — Demonstrates WPF shape drawing elements: Ellipse, Line, Path, Polygon, Polyline, and Rectangle. [page 180]

    • EllipseClick — Changes the color of an ellipse when the mouse is over it and displays a message box when it's clicked. [page 180]

    • FormImage — Displays an image in a Grid control's background. [page 179]

    • ResizingButtons — Makes buttons with fixed height but that resize with their container's width. [page 173]

    • UseBulletDecorator — Demonstrates the BulletDecorator control. [page 173]

    • UseButtonRepeatButton — Demonstrates the Button and RepeatButton controls. [page 178]

    • UseCanvas — Uses a Canvas to exactly position controls. [page 173]

    • UseComboBox — Demonstrates a ComboBox control that contains items having different fonts and images. [page 175]

    • UseDockPanel — Demonstrates the DockPanel control. [page 173]

    • UseExpander — Demonstrates the Expander control. [page 174]

    • UseFrame — Demonstrates the Frame control, which provides navigation among Page objects. [page 180]

    • UseListBox — Demonstrates a ListBox control that contains items having different fonts and images. [page 176]

    • UseMediaElement — Demonstrates the MediaElement control to play a Windows movie (.wmv) file. [page 179]

    • UseMenuContextMenu — Demonstrates the Menu and ContextMenu controls. [page 178]

    • UsePasswordBox — Demonstrates the PasswordBox control. [page 176]

    • UsePopup — Demonstrates the Popup control. [page 177]

    • UsePrintDialog — Demonstrates the PrintDialog control. [page 178]

    • UseProgressBar — Demonstrates the ProgressBar control. [page 177]

    • UseRadioButtons — Demonstrates RadioButton controls in two groups defined by StackPanel controls. [page 176]

    • UseScrollBar — Demonstrates the ScrollBar control and binds two ScrollBars' Value properties to an ellipse's width and height. [page 176]

    • UseScrollViewer — Demonstrates the ScrollViewer control. Shrink the form to make the ScrollViewer display its scroll bars. [page 174]

    • UseSeparator — Demonstrates a Separator control between buttons in a StackPanel. [page 174]

    • UseSlider — Demonstrates the Slider control and binds two Sliders' Value properties to an ellipse's width and height. [page 176]

    • UseStatusBar — Demonstrates a StatusBar control that contains labels, separators, and an image. [page 177]

    • UseTabControl — Demonstrates the TabControl control. [page 174]

    • UseToolBar — Demonstrates three ToolBar controls inside a ToolBarTray. [page 178]

    • UseToolTip — Demonstrates ToolTip controls including one that displays formatted text. [page 177]

    • UseViewbox — Demonstrates a ViewBox control that stretches its contents uniformly when it is resized. [page 174]

    • UseWrapPanel — Demonstrates WrapPanel controls in vertical and horizontal orientations. [page 175]

  • Chapter 12

    • BezierCurves — Draws different kinds of Bézier curves. [page 210]

    • ButtonTemplate — Uses a template to define a button shape and style. [page 199]

    • Calculator — A simple calculator application. [page 196]

    • GradientBackground — Contains a Grid control with a linear gradient background. [page 194]

    • GridButton — Displays a button that contains a grid holding text. [page 186]

    • GridButtonCode — Contains a button at design time. At runtime, adds a Grid to the button and Labels to the Grid. [page 190]

    • GrowingButtons — Catches button MouseEnter and MouseLeave events to animate growing and shrinking buttons when the mouse moves over them. (IMHO this is pretty cool!) [page 214]

    • NineButtons — Displays nine buttons in a Grid. Demonstrates how to divide space among grid row and column definitions. [page 195]

    • ProceduralAnimatedButton — Creates buttons at design time and animates them growing and shrinking when the mouse moves over them. [page 212]

    • ProceduralCalculator — Similar to program Calculator except it creates all of its buttons at runtime. [page 215]

    • RotatedButton — Displays a rotated button. [page 188]

    • RotatedButtons — Displays buttons that are transformed to make them tall, wide, sideways, and rotated. [page 201]

    • RotatingCube — Uses 3D controls to display a cube. Scroll bars let you control the cube's orientation.

    • Shapes — Demonstrates shape controls including Polygon, Polyline, Ellipse, Line, and Path. [page 205]

    • SpinAndGrowButton — Displays a button that uses XAML code to grow and rotate when clicked. [page 204]

    • SpinButton — Displays a button that uses XAML code to rotate when clicked. [page 202]

    • UseFixedDocument — Displays a FixedDocument object inside a DocumentViewer control. [page 218]

    • UseFlowDocument — Displays a FlowDocument object. [page 218]

    • UseFlowDocumentPageViewer — Displays a FlowDocument object inside a FlowDocumentPageViewer. [page 218]

    • UseFlowDocumentReader — Displays a FlowDocument object inside a FlowDocumentReader. Menu commands let you change the viewing mode. [page 217]

    • UseFlowDocumentScrollViewer — Displays a FlowDocument object inside a FlowDocumentScrollViewer. [page 218]

  • Chapter 13

    • BrowserApp — Displays two Page objects in a web browser. [page 226]

    • BrowserWizard — Displays a wizard made up of Page objects in a web browser. [page 230]

    • FrameApp — Displays two Page objects in a Frame control. [page 227]

    • UseDialog — Displays a second WPF window as a dialog. [page 223]

    • UsePageFunction — Uses the PageFunction class to display pages in a web browser. [page 228]

  • Chapter 14

    • AssignJobs — Defines classes that you can view in the Object Browser. Uses XML comments to generate XML documentation.

    • CompilerConstantsInCode — Checks compiler constants that are defined in code or that are automatically defined. [page 248]

    • CompilerConstantsSettings — Checks compiler constants that are defined as settings. [page 247]

    • DebugLevel — Uses a DEBUG_LEVEL constant to determine the amount of debugging output. [page 252]

    • EmployeeAssert — Demonstrates Debug.Assert. [page 249]

    • ShowAssemblyInfo — Displays assembly information. [page 241]

    • WpfCompilerConstantsInCode — WPF version of CompilerConstantsInCode. [page 248]

  • Chapter 15

    • AccessLevelEnum — Defines an Enum and then shows the values returned by its values' ToString methods. [page 309]

    • InitializeArrays — Shows how to initialize 2- and 3-dimensional arrays. [page 292]

    • NullableTypes — Demonstrates nullable type calculations. [page 313]

    • ScopeTest — Demonstrates scope of module-level and local variables. [page 302]

    • ShadowTest — Demonstrates class properties shadowing parent class properties. [page 280]

    • TimeGenericObjects — Compares the speeds of using an integer for a looping variable and using a variable with no declared data type. [page 298]

    • UseDelegates — Demonstrates delegates to shared class methods and instance methods. [page 315]

    • WithEventsControls — Shows how to declare objects with the WithEvents keyword. [page 284]

  • Chapter 16

    • ComplexNumbers — Builds a ComplexNumber class and provides operator overloads to perform arithmetic operations. [page 336]

    • MultiplyTimeSpan — Shows how to multiply a TimeSpan by a number. [page 332]

    • StringBuilderTest1 — Compares the times needed to build a long string with and without the StringBuilder class. [page 329]

    • StringBuilderTest2 — Compares the times needed to build a very long string with and without the StringBuilder class. [page 330]

  • Chapter 17

    • AttributeConditional — Demonstrates the Conditional attribute. [page 340]

    • Flavors — Uses relaxed delegates to declare an event handler's "sender" parameter with a specific data type.

    • HandleMultipleEvents — Uses relaxed delegates to catch dissimilar events with a single event handler.

    • InlineFunction — Demonstrates inline lambda functions. [page 361]

    • LambdaFunction — Demonstrates a lambda function. [page 361]

    • PartialMethods — Demonstrates partial methods. [page 367]

    • RelaxedDelegates — Uses a delegate type to call three routines that declare their parameters differently. [page 365]

    • RelaxedEventHandlers — Uses relaxed delegates in event handler parameters. [page 366]

    • ValidatePhone — Adds extension methods to the String class to see if a String matches a regular expression or looks like a U.S. phone number. [page 360]

  • Chapter 18

    • EnumerateEmployees — Demonstrates a generic enumerator. [page 387]

    • ExitAndContinue — Demonstrates Exit and Continue statements in loops. [page 390]

    • Loops — Demonstrates For Each loops, using an enumerator with Do While Loop, and using an enumerator with While End While. [page 380]

  • Chapter 19

    • ClassicErrorHandling — Demonstrates classic On Error style error handling. [page 413]

    • ClimbStackTrace — Shows how to climb a stack trace. [page 407]

    • CustomException — Shows how to make a custom exception. [page 411]

    • DrawableRect — Shows how to validate parameters and throw ArgumentExceptions. [page 408]

    • GlobalException — Shows how to catch all errors even if an error handler is not active when the error occurs. [page 401]

    • OnErrorGoToMinus1 — Demonstrates On Error GoTo −1. [page 416]

    • ShowExceptionInfo — Shows an exception's Message, StackTrace, and ToString values. [page 406]

    • SortOrders — Shows how a program might protect itself against errors. This program doesn't actually do anything. [page 397]

    • SortValues — Displays and sorts random numbers.

    • ThrowError — Shows how to catch errors with Try Catch. [page 405]

    • ValidateInteger — Uses error handling to validate integer input. [page 400]

  • Chapter 20

    • BindComboBox — Binds a ComboBox. [page 469]

    • BindListBox — Binds a ListBox. [page 471]

    • BindSimple — Uses simple binding on text boxes. [page 467]

    • BindSimpleMemoryDataSet — Uses simple binding on text boxes with a DataSet built in memory. [page 469]

    • CommandInsert — Uses a Command object to insert records. [page 434]

    • DataGrids — Demonstrates multiple DataGrid controls attached to different DataViews. [page 461]

    • GenerateCommands — Uses an OleDbCommandBuilder to get INSERT, UPDATE, and DELETE commands for a data adapter. [page 439]

    • MakeDataSourceFields — A basic program that connects to a data source and displays data one record at a time.

    • MakeDataSourceTable — A basic program that connects to a data source and displays data in a grid. [page 430]

    • MemoryDataSet — Builds a DataSet in code. [page 445]

    • MemoryDataSetNestedXml — Builds a DataSet in code and makes its XML representation include nested records inside parent records instead of in a separate table. [page 458]

    • MemoryDataSetWithErrors — Builds a DataSet in code and assigns errors to some data. [page 453]

    • MemoryDataSetXmlMappedColumns — Builds a DataSet in code and customizes its XML representation. [page 456]

    • Transactions — Demonstrates a transaction. [page 436]

  • Chapter 21

    • AggregateExamples — Demonstrates LINQ aggregates: Average, Count, LongCount, Max, Min, and Sum. [page 488]

    • AnyExamples — Uses lambda functions and the Any function to see if any person has first and last names of the same length.

    • CustomersToXml — Demonstrates LINQ to XML to build XML from LINQ queries. [page 501]

    • FunctionExamples — Demonstrates LINQ functions such as SingleOrDefault, ElementAt, ElementAtOrDefault, Empty, and Range. [page 490]

    • GroupByWithTotals — Demonstrates a Group By clause that selects the Sum of items in a group. [page 487]

    • JoinExamples — Demonstrates join clauses. [page 484]

    • LimitingExamples — Demonstrates limiting clauses such as Take While, Take 4, and Skip While. [page 490]

    • LinqAxes — Demonstrates LINQ axes such as "x_all ... <PositiveBalances> ... <Customer>." [page 505]

    • LinqFunctions — Demonstrates LINQ queries that use code-defined functions. [page 497]

    • LinqLambda — Demonstrates LINQ queries that use LINQ clauses, code-defined functions, and lambda functions. [page 475]

    • LinqLambda2 — Demonstrates LINQ queries that use lambda functions in delegates and lambda functions inline.

    • LinqOrderBy — Demonstrates LINQ queries with Order By clauses.

    • LinqToDataSetScores — Demonstrates DataGrid controls bound to the results of LINQ queries. [page 508]

    • LinqToXml — Uses LINQ queries to make XML objects from list data and to make lists from XML data. [page 502]

    • LinqToXmlFunctions — Uses XML functions such as Ancestors, AncestorsAndSelf, and DescendantsAndSelf to select list data from XML data. [page 505]

    • NestedGroupBy — Demonstrates nested Select and Group By clauses.

    • OrderByExamples — Demonstrates Order By clauses ascending and descending, sometimes modifying the results. [page 479]

    • SetExamples — Demonstrates set clauses and functions such as Distinct, Union, Intersect, and Except. [page 489]

    • SimpleGroupBy — Copies results of relatively simple Group By queries into a TreeView control. [page 486]

    • SimpleSamples — Demonstrates simple LINQ queries, joins, result field selection, and results that of a specific class. [page 478]

  • Chapter 22

    • BreakSignature — Modifies a strongly signed assembly to break its signature.

    • ColorScrollerTest — Includes a composite control. [page 527]

    • EmployeeRegisterTest — Demonstrates control attributes. [page 520]

    • FaceControls — Control library containing the SmileyFace control. [page 516]

    • FaceControlsTest — Test program for FaceControls. [page 517]

    • InvisibleControlTest — Demonstrates a control that is invisible at runtime. [page 531]

    • LabControls — Contains three controls that don't do anything but that you can use to derive a new inherited control.

    • RowSortingListViewTest — Includes the RowSortingListView control that inherits from ListView. [page 523]

    • ShowModeTest — Includes the ShowMode control that indicates whether it is running in design mode or run mode. [page 522]

    • SignedAssembly — A signed DLL library.

    • SignedAssemblyTest — Test program for SignedAssembly.

    • SimpleSmileyControls — Control library containing a SimpleSmiley control that inherits from Control rather than UserControl. [page 529]

    • SimpleSmileyControlsTest — Test program for SimpleSmileyControls.

    • WorkItemControls — Defines a control that has a property that contains a collection. [page 519]

    • WorkItemControlsTest — Test program for WorkItemControls.

  • Chapter 23

    • AcceptDroppedFiles — Displays a list of files dropped onto the program's drop target. [page 546]

    • CopyPasteEmployee — Copies and pastes an Employee object using the clipboard. [page 554]

    • CopyPasteRichText — Copies and pastes data in RFT, HTML, and text formats using the clipboard. [page 552]

    • DragBetweenListBoxes — Lets the user to drag values from one ListBox to another. [page 543]

    • DragBetweenListBoxes2 — Lets the user drag-and-drop to move or copy values from one ListBox to another. [page 543]

    • DragEmployee — Lets the user drag-and-drop an Employee object. [page 547]

    • DragEmployee2 — Lets the user drag-and-drop an Employee object with the data name "Employee." [page 549]

    • DragRichText — Lets the user to drag-and-drop data in RTF, HTML, and text formats. [page 550]

    • DragWithinApp — Lets the user drag data but only within this application. [page 545]

    • LabelDrag — Demonstrates very simple drag-and-drop. [page 542]

    • LabelDrag2 — Demonstrates very simple drag-and-drop while verifying that the dragged data comes in text format. [page 542]

    • PasteFileList — Displays a list of files copied to the clipboard. [page 555]

  • Chapter 24

    • AddShields — Adds UAC shields to buttons, links, and menu items. [page 561]

    • ExecuteMe — Uses a manifest to require administrator privilege to run. [page 563]

    • NoPrivs — A simple program that doesn't use its manifest to require privileges. Program StartRunAs starts this program, requesting privilege elevation. [page 562]

    • ShellUAC — Displays a UAC shield and starts program ExecuteMe, which requires privilege elevation. [page 559]

    • StartRunAs — Uses Process.Start to start program NoPrivs. It sets the process's Verb to runas to require privilege elevation. [page 563]

  • Chapter 25

    • There are no example programs for this chapter.

  • Chapter 26

    • CustomEvent — Demonstrates a custom event. [page 621]

    • FinalizeObjects — Demonstrates object finalization then the program ends. [page 610]

    • GarbageCollection — Creates objects until garbage collection occurs. [page 609]

    • StructuresAndClasses — Demonstrates the fact that setting a class variable equal to another makes them both point to the same object while setting a structure variable equal to another makes a separate copy of the structure. [page 600]

    • UseDispose — Demonstrates using a Dispose method. [page 612]

  • Chapter 27

    • DrawDashes — Draws a dashed rectangle inside the form. [page 628]

    • DrawDashesImportsDashStyle — Draws a dashed rectangle inside the form. It imports the DashStyle enum to make the code easier to read. [page 633]

    • DrawDashesWithImports — Draws a dashed rectangle inside the form. It imports System.Drawing.Drawing2D to make the code easier to read. [page 629]

    • JobNamespaces — Demonstrates namespaces. [page 632]

    • NamespaceHierarchy — Defines a namespace hierarchy. [page 634]

  • Chapter 28

    • ArraySpeeds — Compares the speed of normal arrays with Array objects. [page 646]

    • ArrayTests — Demonstrates the Array class methods IndexOf, LastIndexOf, Reverse, and BinarySearch. Also sorts integers, objects that implement IComparable, and objects that can be sorted with IComparer objects. [page 648]

    • GenericEmployeeList — Derives a strongly typed EmployeeList class from the generic List(Of Employee) class. [page 666]

    • GenericStringList — Demonstrates a generic List(Of String). [page 647]

    • MakeEmployeeCollection — Builds a strongly typed collection of Employee objects. [page 654]

    • MakeEmployeeDictionary — Builds a strongly typed dictionary of Employee objects. [page 660]

    • MakeEmployeeListDictionary — Builds a strongly typed list dictionary of Employee objects. [page 660]

    • ShowSquares — Builds a normal array and an Array object containing squares of numbers. [page 642]

    • UseArrayList — Demonstrates ArrayList methods. [page 651]

    • UseCaseInsensitiveSortedList — Demonstrates a case-insensitive SortedList. [page 661]

    • UseNameValueCollection — Demonstrates the NameValueCollection class. [page 655]

    • UseQueue — Demonstrates a Queue. [page 665]

    • UseSortedList — Demonstrates the SortedList class. [page 661]

    • UseStack — Demonstrates a Stack. [page 663]

  • Chapter 29

    • GenericEmployeeList — Derives a strongly typed EmployeeList class from the generic List(Of Employee) class.

    • GenericMruList — Builds a generic MostRecentList(Of ItemType) class. [page 673]

    • GenericMruList2 — Builds a generic MostRecentList(Of ItemType As IComparable) class. [page 677]

    • GenericNumDistinct — Demonstrates a generic extension method. [page 682]

    • GenericPairDictionary — Builds a generic PairDictionary(Of KeyType, DataType1, DataType2) class. [page 676]

    • GenericTree — Builds a generic Tree(Of DataType) class and uses derived classes to make building objects easier. [page 679]

    • GenericTreeImportsAlias — Builds a generic Tree(Of DataType) class and uses Imports aliases to make building objects easier. [page 679]

    • GenericTreeSubclass — Builds a generic Tree(Of DataType) class and makes a PersonTree class that inherits from Tree(Of Person) to make building objects easier. [page 680]

    • UseSwitcher — Demonstrate a generic Switch method. [page 681]

  • Chapter 30

    • AntiAliasing — Draws text with and without anti-aliasing. [page 698]

    • Bezier — Draws a Bézier curve. [page 701]

    • Beziers — Draws a series of Bézier curves. [page 689]

    • ClosedCurve — Draws a closed curve. [page 710]

    • ClosedCurveTensions — Draws closed curves with different tensions. [page 710]

    • DrawTextPath — Draws an outline of some text. [page 703]

    • HatchStyles — Draws samples of the available hatch styles. [page 694]

    • InterpolationModes — Demonstrates different InterpolationMode values. [page 708]

    • LineCaps — Draws sample line end caps. [page 693]

    • LineJoins — Draws sample corner joins. [page 701]

    • ListInstalledFonts — Lists and displays samples of installed fonts. [page 696]

    • MapRectangle — Uses transformations to change where an image is drawn. [page 723]

    • OrangeAndBlueEllipse — Draws a blue ellipse filled with orange.

    • PaintResizeX — Demonstrates redrawing when resizing. [page 718]

    • SaveRestore — Saves and restores graphics state to draw rotated rectangles. [page 716]

    • ScaleDiamond — Draws a diamond scaled around its center. [page 713]

    • SmoothingModes — Displays samples using different SmoothingMode values.

    • TextRenderingHints — Displays sample text for different TextRenderingHint values.

    • TransformArrow — Demonstrates a translation followed by a rotation. [page 712]

    • TransformationOrder — Shows that a translation followed by a rotation is not the same as a rotation followed by a translation.

  • Chapter 31

    • CompoundArrays — Draws lines that are striped lengthwise. [page 725]

    • CustomLineCaps — Draws a custom line cap. [page 735]

    • GraphicsPathClip — Draws lines clipped by a GraphicsPath. [page 743]

    • GraphicsPathFillMode — Demonstrates the alternate and winding fill modes. [page 752]

    • GraphicsPathTextRegion — Clips a form to a text path. [page 742]

    • GraphicsPathTextureBrush — Fills text with a tiled image. [page 741]

    • HatchStyles — Shows samples of the available hatch styles. [page 732]

    • LinearGradientBrushes — Demonstrates linear gradient brush features such as blends, sigma bell shape, and wrap mode. [page 735]

    • LineCaps — Displays samples of the available line caps.

    • LineJoins — Demonstrates line join styles (miter, bevel, clipped).

    • PathGradientBrushes — Demonstrates path gradient brushes. [page 740]

    • PenAlignments — Demonstrates pen alignments (insert or center). [page 724]

    • TransformedPen — Demonstrates a pen transformation. [page 728]

    • TransformedTextureBrush — Fills a polygon with a transformed image. [page 739]

    • UseDispose — Use the Dispose method to free Pen, Brush, and Graphics resources. [page 746]

    • UseSolidBrush — Demonstrates using stock solid brushes. [page 729]

    • UseUsing — Uses Using statements to free Pen, Brush, and Graphics resources. [page 747]

    • WrapModes — Demonstrates image tiling wrap modes.

  • Chapter 32

    • DirectionVertical — Draws text rotated 90 degrees. [page 753]

    • DrawStringCrLfTab — Draws text containing vbCrLf and tabs.

    • DrawStringLayoutRect — Uses a layout rectangle to align text. [page 759]

    • DrawStringSimple — Draws a simple string. [page 758]

    • FontMetrics — Displays measurements for three fonts. [page 762]

    • MeasureCharacterRanges — Displays positions for the character in a string. [page 758]

    • MeasureString — Measures a string and draws a box showing its size. [page 757]

    • NoClipLineLimit — Demonstrates string formatting flags that determine how text is clipped. [page 761]

    • SetTabs — Sets tab stop positions and then draws text containing tabs. [page 755]

    • TransformedText — Draws text rotated 60 degrees. [page 755]

    • Trimming — Shows different ways to use the StringFormat object's Trimming property to control how text is trimmed. [page 755]

  • Chapter 33

    • AutoRedraw — Draws an image when the form loads or resizes. Save the result in a PictureBox's Image property so it doesn't need to handle Paint events. [page 771]

    • InvertImageGetSetPixels — Inverts the pixels in an image by using the Bitmap object's GetPixel and SetPixel methods. [page 773]

    • InvertImageUnsafe — Uses "unsafe" methods to invert an image's pixels. [page 775]

    • LoadPicture — Loads a picture from a file and copies it so the file isn't locked. [page 769]

    • MakeMetafile — Makes a metafile and draws it twice at different sizes. [page 781]

    • SaveJpeg — Saves an image in a JPEG file. [page 780]

    • Scribble — Lets the user draw with the mouse. [page 772]

  • Chapter 34

    • CenterPicture — Prints a picture centered on the page. [page 793]

    • FitToMargins — Prints a picture enlarged to fit the page without distortion. [page 795]

    • PictureBoxPrint — Draws a picture on a form and displays a print preview scaled to fit the page without distortion. [page 797]

    • PrintBooklet — Prints a multi-page document with gutters and page numbers on alternating sides. [page 787]

    • PrintMargins — Draws rectangles around the page's margins and bounds.

    • PrintSimple — Displays a print preview or print dialog, or prints a simple diamond shape.

    • UsePrintPreviewControl — Demonstrates the PrintPreviewControl control.

    • UsePrintPreviewDialog — Displays a print preview or print dialog, or prints three pages. [page 785]

  • Chapter 35

    • CatchThreadException — Uses AddHandler at runtime to add an event handler to catch thread exceptions. [page 831]

    • ConfigFile — Demonstrates properties bound to configuration file values. [page 816]

    • EmbeddedResources — Loads data from resources at runtime. [page 821]

    • EnvironmentVariableLevels — Gets and sets environment variables on the system, user, and process level. [page 809]

    • FilterMessages — Filters out the form's WM_LBUTTONDOWN messages so left-clicks are ignored. [page 830]

    • GetEnvironValue — Uses the Environ collection to list environment variables. When the user selects one, displays its value.

    • ListEnviron — Uses the Environ collection to list environment variables and their values. [page 807]

    • ListEnvironValues — Uses the Environ collection to list environment variables and their values in a ListView. [page 807]

    • ListForms — Uses the Application.OpenForms collection to list the program's open forms. [page 828]

    • Localized — This program is localized for English and German. The system automatically picks the best localization for the system. [page 823]

    • LocalizedPickLanguage — Uses a ComponentResourceManager to change locales at runtime. [page 826]

    • LocalizedPickLanguage2 — Changes the current thread's CurrentCulture and CurrentUICulture, and then uses a ComponentResourceManager to change locales at runtime. [page 827]

    • LocalizedUseGerman — Uses a customized form constructor to select the German locale. [page 824]

    • MyComputerRegistry — Uses Registry objects to get, set, and delete Registry values. [page 813]

    • RegistrySettings — Uses GetSetting, SaveSetting, GetAllSettings, and DeleteSetting to get, set, and delete Registry values. [page 811]

    • SatelliteMain — Main program that loads resources from satellite assembly SatelliteResourcesDll.dll. [page 822]

    • SatelliteResourcesDll — Satellite resource-only assembly. [page 822]

    • SaveSettings — Demonstrates saving user-scope settings in My.Settings. [page 818]

    • ShowProductInfo — Displays the application's CompanyName, ProductName, and ProductVersion. [page 828]

    • ShowSettings — Displays a list of the program's settings. [page 818]

    • SystemEnvironment — Displays System.Environment values including a stack trace. [page 808]

    • UseResources — Loads values from resources at runtime. [page 820]

  • Chapter 36

    • FileStreamWrite — Uses a FileStream to write "Hello world!" into a file. [page 836]

    • MemoryStreamWrite — Writes into a MemoryStream, seeks to its beginning, and reads the text back. [page 837]

    • OpenCreateAppendText — Shows how to see if a file exists, open an existing file, create a new file (overwriting the old one if it exists), and append to an existing file. [page 844]

    • ReadLines — Demonstrates the StreamReader's ReadLine and EndOfStream methods. [page 842]

    • StreamWriterReader — Uses StreamWriter and StreamReader objects to write and then read a text file. [page 843]

    • StringWriterReader — Uses StringWriter and StringReader objects to write and then read a string. [page 842]

  • Chapter 37

    • GetDriveInfo — Uses the DriveInfo class to get information about the system's drives. [page 868]

    • InvalidCharacters — Uses Path.GetInvalidFileNameChars and Path.GetInvalidPathChars to list characters that are not allowed in file names and paths. [page 852]

    • RandomAccessEmployees — Makes fixed-sized records in a file and then randomly accesses them.

    • ShowSpecialDirectories — Uses My.Computer.FileSystem.SpecialDirectories to list the system's special directories.

    • UseFileSystemWatcher — Uses a FileSystemWatcher to take action when a file is created in the program's startup directory. [page 865]

    • UseFindInFiles — Uses My.Computer.FileSystem.FindInFiles to search for files containing a string.

    • VbFileMethods — Uses Visual Basic file methods to open a file and read it one line at a time.

    • WriteFile — Uses System.IO.File.WriteAllText to write a file.

  • Chapter 38

    • QuoteClient — Program that uses the QuoteServiceLib service routines. [page 878]

    • QuoteServiceLib — Service that generates random quotes. [page 874]

  • Chapter 39

    • AesFile — Encrypts and decrypts a file using the AES algorithm. [page 890]

    • BuildMemoryXml — Uses an XmlTextWriter to write information about Employee objects "by hand." [page 889]

    • DesFile — Encrypts and decrypts a file using the DES algorithm. [page 893]

    • ParallelFor — Uses Parallel.For to execute multiple threads simultaneously. [page 901]

    • ParallelForEach — Uses Parallel.ForEach to execute multiple threads simultaneously. [page 901]

    • ParallelInvoke — Uses Parallel.Invoke to execute multiple threads simultaneously. [page 899]

    • ReflectionFormProperties — Uses reflection to list the form's properties.

    • ReflectionGetResources — Uses reflection to list and display resources from ReflectionHasResources.

    • ReflectionHasResources — Creates a resource-only DLL. [page 887]

    • RegExHighlight — Uses regular expressions to find multiple matching expressions and highlights them in the output. [page 887]

    • RegExReplace — Uses regular expressions to make multiple replacements in a string. [page 887]

    • RegExValidate — Uses regular expressions to see if a test string matches a pattern. [page886]

    • SystemSounds — Plays the system sounds. [page 884]

    • ThreadGraph — Uses a Thread to draw a graph while allowing the main program to respond to events.

    • UseBackgroundWorker — Demonstrates a BackgroundWorker component controlling a simulated long task.

  • Appendix A

    • DisplayRectangles — Shows a GroupBox's DisplayRectangle and ClientRectangle. [page 918]

    See the chapter listings for more examples that demonstrate control properties, methods, and events. In particular, see Chapter 8, "Selecting Windows Forms Controls," and Chapter 9, "Using Windows Forms Controls."

  • Appendix G

    • CustomColorDialog — Displays a color dialog with custom colors. [page 957]

    • FlowDirections — Demonstrates the FlowLayoutPanel control's FlowDirection property values LeftToRight, RightToLeft, TopDown, and BottomUp. [page 964]

    • ListViewCustomSort — Uses an IComparer class to implement a custom sort for the ListView control. Also shows how to let the user select different display modes. [page 979]

    • MultiLineLabel — Uses a multiline label.

    • RunTimeListView — Inserts data into a ListView control at runtime.

    • UseBackgroundWorker — Demonstrates a BackgroundWorker component controlling a simulated long task. [page 953]

    • UseButton — Demonstrates a button.

    • UseCheckedListBox — Displays a CheckedListBox that displays Employee objects (shows how to display objects in a ListBox or ComboBox). Shows how to enumerate the selected items. [page 956]

    • UseColorDialog — Shows how to let the user select a color. [page 957]

    • UseComboBox — Demonstrates the ComboBox control and its different DropDownStyle values. [page 966]

    • UseDataGridView — Demonstrates a DataGridView control attached to a database.

    • UseDateTimePicker — Demonstrates the DateTimePicker control. [page 968]

    • UseDomainUpDown — Uses the DomainUpDown control to let the user select a month by name.

    • UseErrorProvider — Use an ErrorProvider component to display an error indicator if the user doesn't enter a five-digit ZIP code. [page 963]

    • UseFolderBrowserDialog — Demonstrates the FolderBrowserDialog component.

    • UseFontDialog — Demonstrates the FontDialog. [page 967]

    • UseFontDialogWithShowEffects — Demonstrates the FontDialog. Allows the user to click the Apply button to show the new font on the form, and then cancel or okay the changes. [page 967]

    • UseGroupBox — Demonstrates GroupBoxes containing RadioButtons.

    • UseHelpProvider — Uses a HelpProvider to display a help popup if the user selects a field and presses F1.

    • UseHScrollBar — Demonstrates the HScrollBar control.

    • UseLinkLabel — Demonstrates the LinkLabel control and shows how to open a web site when the user clicks a link.

    • UseListView — Demonstrates the ListView control and its display modes. [page 976]

    • UseMonthCalendar — Demonstrates the MonthCalendar control. Sets the control's minimum, maximum, and current dates; selects date range; and bolds Mondays. [page 987]

    • UseMonthCalendarInDialog — Shows how to make a dialog that displays a MonthCalendar control that shows two rows of three months. The dialog lets the user pick a date range and returns OK or Cancel. [page 987]

    • UseNotifyIcon — Demonstrates the NotifyIcon component and shows how to add a ContextMenu to the notification icon. [page 987]

    • UseNumericUpDown — Demonstrates the NumericUpDown control.

    • UseOpenFileDialog — Demonstrates the OpenFileDialog component. Shows how to catch the FileOk event to validate the user's selection.

    • UsePageSetupDialog — Demonstrates the PageSetupDialog.

    • UsePanel — Demonstrates a Panel with AutoScroll. Lets the user set the control's AutoScrollPosition.

    • UsePictureBox — Shows three ways to draw on PictureBoxes: by assigning an image to a PictureBox's Image property, by drawing in the PictureBox's Paint event handler, and when the code executes so the image is not refreshed later.

    • UsePrintDialog — Demonstrates the PrintDialog component.

    • UsePrintPreviewControl — Uses a PrintPreviewControl control to display three pages of printout inside a form. [page 1000]

    • UsePrintPreviewDialog — Uses a PrintPreviewDialog to display three pages of printout in a dialog.

    • UseProcess — Demonstrates the Process component by using it to start a new process running this program. [page 1002]

    • UseProgressBar — Demonstrates the ProgressBar control.

    • UsePropertyGrid — Displays Employee object data in a ListBox and a PropertyGrid. [page 1011]

    • UseRadioButton — Demonstrates RadioButton controls inside GroupBoxes.

    • UseRichTextBox — Demonstrates the RichTextBox control. Shows how to apply colors to selections and how to use the control's undo and redo features. [page 1009]

    • UseSaveFileDialog — Demonstrates the SaveFileDialog component. Shows how to catch the FileOk event to validate the user's selection.

    • UseSplitContainer — Demonstrates a SplitContainer control containing two PictureBoxes. The two Panels automatically provide scroll bars if they are sized so their images don't fit.

    • UseStatusStrip — Demonstrates a StatusStrip control containing a menu, progress bar, image, and label that displays the time.

    • UseTabControl — Demonstrates the TabControl.

    • UseTabControlOwnerDrawn — Demonstrates an owner-drawn TabControl. [page 1016]

    • UseTableLayoutPanel — Demonstrates the TableLayoutPanel control. Its row heights are set to auto size so each row sizes itself to hold its contents.

    • UseTextBox — Demonstrates TextBoxes. (This program is the same as UseTableLayoutPanel, which contains TextBoxes.)

    • UseTimer — Demonstrates three Timer components running at different speeds.

    • UseToolStrip — Demonstrates a ToolStrip containing a button, label, combo box, drop-down menu containing images, text box, and progress bar.

    • UseToolStripContainer — Demonstrates a ToolStripContainer holding six ToolStrip controls including two oriented vertically (TextDirection=Vertical90 or TextDirection=Vertical270). [page 1030]

    • UseToolStripContainer2 — Demonstrates a ToolStripContainer holding six ToolStrip controls. When you drag a ToolStrip to a new side of the container, the code sets the strip's orientation appropriately.

    • UseToolTip — Demonstrates the ToolTip extender provider. Shows how to set ToolTip text at design time or runtime.

    • UseTrackBar — Uses TrackBar controls to let the user set the red, green, and blue components of a color.

    • UseTreeView — Demonstrates the TreeView control. Shows how to create TreeView nodes at runtime and how to allow the user to edit node labels except those at the top level. [page 1028]

  • Appendix K

    • Constructors — Demonstrates constructors and ways to initialize objects. [page 1062]

  • Appendix M

    • GenericExamples — Demonstrates various generic classes, extensions, and methods. [page 1075]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.134.188