Export (0) Print
Expand All
7 out of 8 rated this helpful - Rate this topic

Code for Windows Forms Controls

Visual Studio .NET 2003

This topic is designed to help you find code that demonstrates how to perform common programming tasks with Windows Forms controls. The following categories are represented in the list below:

You can also find sample code for Windows Forms applications in these locations:

Putting Controls on Forms

Example of...

Adding controls dynamically

Adding components dynamically

Arranging Controls

Example of...

Layering controls

Positioning controls

Resizing controls

Labeling Controls

Example of...

Setting control text

Displaying an image

Creating access keys

Providing accessibility information

Button Control

Example of...

Specifying a default (accept) button

Specifying a cancel button

Responding to a button click

CheckBox Control

Example of...

Responding when the user checks the check box

Determining the state of the check box

Taking action based on the check box state

ColorDialog Component

Example of...

Configuring the dialog box

Setting colors based on the user's selection

ComboBox, ListBox, CheckedListBox Controls

Example of...

Adding or removing items

Determining which items in a check box list are checked

Getting individual values

Data binding

DataGrid Control

Example of...

Formatting

Adding tables and columns

Data binding

Deleting columns

Hiding columns

Changing data at run time

Displaying master-detail data

Responding when a user clicks or selects items

Responding when the user edits items

Validating user input

Creating a simple data access form

DateTimePicker Control

Example of...

Setting dates

Determining the selected date

Formatting the displayed date

DomainUpDown Control

Example of...

Adding items

Removing items

ErrorProvider Control

Example of...

Displaying an error icon

Displaying data-binding errors

FolderBrowser Control

Example of...

Determining what folder the user selected

FontDialog Component

Example of...

Setting fonts based on the user's selection

ImageList Component

Example of...

Adding or removing images

Label Control

Example of...

Creating access keys with labels

LinkLabel Control

Example of...

Formatting

Creating links

ListView Control

Example of...

Adding and removing items

Adding columns

Displaying icons

Creating subitems

MainMenu, MenuItem, ContextMenu Components

Example of...

Adding menus to a form

Changing menus dynamically

Moving menu items

Copying items

Enablding and disabling items

Merging items

Hiding items

Adding check marks, shortcut keys, or access keys

Removing menu items

Removing items from a context menu

Rearranging menu items

Adding check marks and shortcut keys to menus

Adding context menus to forms

Creating a simple application using context menus

MonthCalendar Control

Example of...

Formatting the calendar

Formatting a specific date

Displaying multiple months

Selecting a date range

NotifyIcon Component

Example of...

Adding icons to the taskbar

Linking a context menu to an icon

NumericUpDown Control

Example of...

Setting or getting the value

Formatting numbers

OpenFileDialog Component

Example of...

Opening a file based on the user's selection

PageSetupDialog Component

Example of...

Setting print properties based on the user's selections

Panel Control

Example of...

Adding or removing controls dynamically

Setting panel appearance

PictureBox Control

Example of...

Positioning and sizing images

Setting or clearing the image

PrintDialog, PrintDocument, PrintPreviewDialog Components

Example of...

Creating a standard print job

Allowing the user to specify print options

Choosing a printer

Printing graphics

Printing text

Displaying a message that a print job has finished

Allowing print preview

ProgressBar Control

Example of...

Displaying current progress

RichTextBox Control

Example of...

Responding when the user changes text format

Creating Web-style links

Enabling drag and drop

Displaying the contents of files

Saving contents as a file

Applying character formatting

Applying paragraph formatting

SaveFileDialog Component

Example of...

Saving a file based on the user's selection

Splitter Control

Example of...

Creating an Outlook-like user interface

StatusBar Control

Example of...

Adding panels

Setting panel size

Displaying status bar values at run time

Determining which panel was clicked

TabControl Control

Example of...

Adding a TabControl to a page

Adding and removing tabs

Formatting tab appearance

Enabling tabs

Disabling tabs

TextBox Control

Example of...

Getting or setting text box values

Setting the location of the insertion point

Selecting text

Using the text box for passwords

Adding characters into a text box

Timer Component

Example of...

Running processes at set intervals

ToolBar Control

Example of...

Adding buttons

Displaying icons

Responding when the user clicks a toolbar button

ToolTip Component

Example of...

Setting ToolTip characteristics

Assigning tool tips to controls

TreeView Control

Example of...

Adding or removing nodes

Displaying icons

Adding custom information to nodes

Determining what node the user clicked

Iterating through all nodes

Creating an Outlook-like user interface

Related Code Examples

Code for Windows Forms Applications

Code Examples for Visual Basic Programmers

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.