Charlie Calvert on Elvenware

Writing Code and Prose on Computers

Elvenware

A Listing of the C# Snippets Available for VS 2005

You can download these snippets from the C# Developer Center.

application
appActNa Activates a running application using the name of the application. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
appActPro Activates an application window using the process ID of the application. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
appOutCap Saves the output from a command console application to a string.
appChanCol Changes the background and text color of the console window.
appCOVersion Checks for current version using ClickOnce. For this code snippet to compile, add a reference to System.Deployment.
appCheckUp Checks whether updates to the application are available for download. For this code snippet to compile, add a reference to System.Deployment.dll.
appWinClear Clears the console window.
appIsoDel Deletes file from isolated storage.
appIsoAmt Determines the Amount of Isolated Storage Available.
appIsoScope Determines the scope of isolated storage
appDownload Downloads files synchronously using ClickOnce. For this code snippet to compile, add a reference to System.Deployment.dll.
appRes Returns a list of all the resources in an assembly.
appCur Sets the cursor of a Windows form from a cursor file that is an embedded resource of the application. For this code snippet to compile, add a reference to System.Deployment and make sure that a strongly typed resources class exists for this project (to generate one go to project | properties and select the Resources tab).
appLoad Loads an assembly at run time.
appAsynchMeth Makes an asynchronous method call using the BackgroundWorker component.
appConRW Writes a prompt and then reads in the user request. It is run from a console application.
appArgs Iterates through the command line arguments. This snippet should be used in the Main method.
appIsoRead Reads the text from a file in isolated storage.
appImage Assigns an image resource in the project designer to the PictureBox1's Image property.
appResText Retrieves the text from a file that is an embedded resource of an assembly.
appIsoSave Writes a string to the assembly or user-isolated storage.
appKeys Send keystrokes to the active application.
appStop Closes all the running instances of Notepad.
appUpdateAsync Updates ClickOnce application asynchronously.
appUpdateSync Update a ClickOnce application Synchronously.
appEvent Writes a message to the application event log.
collections and arrays
arrConv Converts an ArrayList to a strongly typed array using ToArray(Type)
colCreate Creates a collection to hold a specific type of items.
colCreateKey Creates a dictionary to hold specific types of items indexed by key.
colCreateSort Creates a sorted dictionary to hold a specific type of items.
arrComp Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
colIndex Indexes into strongly typed dictionary by using a key.
arrInit Initializes a one-dimensional array.
colIter Iterates through specific item types in a collection.
colIterDict Iterates through all the items in a dictionary.
colIterSort Iterates through all the items in a dictionary based on the sorted list of keys.
arrLoc Finds the index of a given element in an array.
arrSort Declares an array of strings, populates it, and then sorts it alphabetically.
connectivity
conConv Converts a relative Uri to an absolute Uri
conAvail Determines whether the network connection is available on the local computer.
conDown Downloads a file using http.
conPorts Shows how to enumerate serial ports.
conPing Determines whether the specified Web site responds.
conReadPort Reads Data from a Serial Port
conEmail Creates and sends an email message.
conUpload Uploads a local file to the Internet.
conDialSer Uses a SerialPort to dial a phone number.
Crystal Reports
crChangeDBLogon Changes a Server name and Database name used by the report. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crExportRptToDisk The following code example exports a Crystal Report to a file. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crExportRptWithOptions The following code example exports a Crystal Report to a PDF file with custom export format options. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crPrintRpt The following code example prints a Crystal Report to the printer specified in the PrintOptions. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crSetDiscreteParam The following code example sets a discrete parameter value. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crSetRangeParam The following code example sets a range parameter value. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
crSetDBLogon Sets a database logon to a Crystal Report and its subreports. For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.
database
adoNewRow Adds a new row to a typed DataTable. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoExecNonQuery Calls ExecuteNonQuery on an existing command. Wraps the execution in a try/finally block to return the connection object to it's previous state. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoExecReader Fetches data from a database using the SqlCommand.ExecuteReader method of a data command. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoExecScalar Executes a SQL statement that returns a single value using the SqlCommand.ExecuteScalar method of a data command. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
dtBindingSourceCurrent Gets the current row within a binding source and converts it to the specific row. Recomended method for capturing the current, rather then using BindingSource.Position which may return a different row based on the sorting of the DataView. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoAddRelation Creates a data relation between two data tables in a dataset. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoAddExpression Creates a DataColumn object and sets the DataColumn.Expression property to calculate the order total. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoSelectwParams Calls the ExecuteReader method of a data command to execute a Select statement. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoSprocWParams Constructs a command object for executing a stored procedure with parameters. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoCreateSqlExpConn Creates a SQL Connection providing replacements for the typical connection name/value pairs for a SQL Express Connection using User Instance=True. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoCreateSqlConn Creates a SQL Connection providing replacements for the typical connection name/value pairs. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
dtTableAdaptPartial Extends a TableAdapter using partial classes. Includes the namespace required to reference existing TableAdapters.
adoTryCatch Implements a try/catch block that handles Exception, DataException, and all the exceptions that derive from DataException. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
adoAccess Loads the data from one table in an Access database into a DataSet object. For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.
dtNonQueryOutParam TableAdapter methods that "Retun No Value" use ExecuteNonQuery which returns the rows affected. This Snippet returns the value from one of the command parameters on a TableAdapter.
datatypes
typeByteStr Convert an Array of Bytes into a String
typeHex Returns the hexadecimal representation of an integer. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
typeOct Returns the octal string representation of an integer. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
typeStrByte Converts a string to a byte array.
typeHiragana Converts between Hiragana and Katakana characters in a String. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
typeSimpleTrad Converts between Simplified Chinese and Traditional Chinese characters in a String. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
typeWidth Converts between Wide and Narrow characters in Strings. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
typeDate Calculates the difference in days between two dates and also constructs a TimeSpan value for that difference.
typeTime Calculates the difference in seconds between two times in the same day, and also constructs a TimeSpan value for that difference.
typeMulti Constructs a string literal that is three lines long.
typeParseEmail Returns the user name and provider name from an e-mail address.
typeRemove Removes all occurrences of one string from another string.
filesystem
fileComp Compares two files.
filCopyDir Copies a directory and all its files and subdirectories.
filCopyFile Copies the file Source.txt to a second file, Copy.txt.
filCreateFile Creates a new file.
filCreateFold Creates a new folder on the computer.
filCreateTemp Creates a name for a temporary file.
filDelFile Deletes a file after confirming deletion with the user. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
filExistFile Sets a Boolean variable indicating whether a specified file exists.
filExistFold Sets a Boolean variable indicating whether a specified folder exists.
filSize Obtains an array of FileInfo objects for the files in the specified directory, and writes the name and length of each file to the console.
filDrives Enumerates the drives on a computer.
filSpace Obtains the amount of disk space available.
filFileInfo Obtains an object containing information about a file.
filMoveFile Moves a file to a new directory.
filParseText Returns the values in each column and row from a text file with comma-delimited data. Other delimiters may be used. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
filReadBin Reads data from a binary file.
filReadMy Reads the contents of a text file in the My Documents folder into a single string.
filReadText Reads the contents of a text file into a single string.
filRenDir Renames a directory.
filRenFile Renames a file.
filDriveNames Retrieves the drive names on the local computer.
filSearchDir Searches a directory for files recursively.
filSearchTxt Searches files in a directory for an expression.
filWriteText Writes a line of text to a text file, replacing any text if the file exists.
filWriteBin Writes bytes to a binary file.
Math
mathPayLoan Calculates the monthly payment on a loan. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
mathCos Converts an angle from degrees to radians and then calculates cosine of the angle
mathDep Returns a Double specifying the sum-of-years digits depreciation of an asset for a specified period. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
mathSin Converts an angle from degrees to radians and then calculates sine of the angle
mathTan Converts an angle from degrees to radians and then calculates the tangent of the angle
mathRand Generates a random integer between an upper bound and a lower bound.
OS
osUser Finds the current users name.
osPower Performs an action when the system power mode changes.
osTimer Responds to a timer event. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
osInvoke Uses BeginInvoke on a control to run code asynchronously.
OS\EventLog
evReadApp Creates an array of EventLogEntry objects from the Application Log written by the "SourceName" source.
evReadLog Reads all event log entries.
evWriteApp Writes a message to the application Event Log
evWriteLog Writes a string to the application event log on the local computer.
OS\Messaging
mqCreate Creates a public message queue on the local computer. For this code snippet to compile, add a reference to System.Messaging.dll.
mqCreatePriv Creates a private message queue on the local computer. For this code snippet to compile, add a reference to System.Messaging.dll.
mqPeek Uses the Peek method to look at the first message on the queue without removing that message from the queue. For this code snippet to compile, add a reference to System.Messaging.dll.
mqPurge Uses the Purge method to clear the contents of any queue to which you have access rights in the Message Queuing system. For this code snippet to compile, add a reference to System.Messaging.dll.
mqList Retreives the message queues on the local computer. For this code snippet to compile, add a reference to System.Messaging.dll.
mqLabels Retrieves and array of messages and creates an array of the message labels. For this code snippet to compile, add a reference to System.Messaging.dll.
mqSend Sends a text message to a queue on the local computer. For this code snippet to compile, add a reference to System.Messaging.dll.
mqSendRec Sends a message to a queue on the local computer, receives that message, and formats the body as a string. For this code snippet to compile, add a reference to System.Messaging.dll.
mqFormat Determines how a message body is deserialized. For this code snippet to compile, add a reference to System.Messaging.dll.
OS\Process
procList Creates a string that contains a list of running application processes.
procBrowser Opens a webpage in the default browser.
procRun Runs a program associated with a file type.
procStart Starts the Notepad application.
procStop Stops a running application.
OS\Registry
regCreate Creates a registry key.
regDel Deletes a registry key.
regExist Checks to see if the specified key exists.
regRead Reads a string registry value from the current user hive.
regWrite Writes a string registry value to the current user hive.
OS\Services
servCont Uses the ServiceController component to continue the IIS Admin service on the local computer. For this code snippet to compile, add a reference to System.ServiceProcess.dll.
servPause Uses the ServiceController component to pause the a service on the local computer. For this code snippet to compile, add a reference to System.ServiceProcess.dll.
servList Creates a string of array of the services on the local computer. For this code snippet to compile, add a reference to System.ServiceProcess.dll.
servStart Starts a Windows service application. For this code snippet to compile, add a reference to System.ServiceProcess.dll.
servStop Stops a Windows service application. For this code snippet to compile, add a reference to System.ServiceProcess.dll.
OS\SystemInfo
sysChgPref Creates as structure for handling changes in user settings.
sysCreateVar Creates a user environment variable that persists between program executions.
sysRes Determines the width and height, in pixels, of the desktop. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sysMem Determines the amount of system memory currently available. For this code snippet to compile, add a reference to Microsoft.VisualBasic.dll.
sysOS Determines the version of Windows in use
sysDir Sets a string containing the path of the Windows system directory.
sysSpace Returns the amount of available disk space on a specified drive.
sysListVar Creates a string that lists all the user environment variables and their values.
sysAccess Gets a value indicating whether the user has selected to run in high-contrast mode. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
sysReadVar Retrieves the value of an environment variable.
sysIcon Retrieves the user preferences for icon display properties. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sysKey Retrieves the user's keyboard settings. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
sysMenu Retrieves several menu settings. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sysMouse Retrieves several mouse settings. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sysRegion Retrieves various regional settings.
sysColor Retrieves just two of the many system color settings. For this code snippet to compile, add a reference to System.Drawing.dll.
sysPower Retrieves the percent of battery life left, and warns the user if the percent is below five percent. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
sysTime Retrieve the current time on the local computer.
Security
secHashPass Computes the hash code of a password cryptographically. For this code snippet to compile, add a reference to System.Security.dll.
secHashStr Computes the hash of a string using three different algorithms. For this code snippet to compile, add a reference to System.Security.dll.
secDecrypt Decrypts a file. For this code snippet to compile, add a reference to System.Security.dll.
secEncrypt Encrypts text from a file using the Rijndael encryption algorithm. For this code snippet to compile, add a reference to System.Security.dll.
secUser Retrieves the name of the user.
secRanNum Generates cryptographically random data. For this code snippet to compile, add a reference to System.Security.dll.
smartdevices\application
sdres Shows how to get an embedded resource, .bmp file, and display it in a PictureBox. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sddir Gets the directory containing the assembly of the application. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sdculture Displays current locale, culture information, configured for the device. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
sdname Gets the device name from network settings. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
smartdevices\connectivity
sdirdadis Determines infrared devices in proximity to the device. For this code snippet to compile, add a reference to System.Windows.Forms.dll, System.Net.IrDA.dll and System.Drawing.dll.
sdirdarec Receives a text file using infrared transmission from another device. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Net.IrDA.dll.
sdirdatran Sends a text file using infrared transmission to another device. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Net.IrDA.dll.
sdhttp Submits an HTTP GET request using a proxy.
smartdevices\database
sddgadd Adds Rows and Columns to a DataGrid. For this code snippet to compile, add a reference to System.Windows.Forms.dll, System.Data.dll, and System.Xml.dll.
sddgedit Allows you to edit the cells in a DataGrid. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Data.dll.
sddgsource Sets the DataSource of a DataGrid. For this code snippet to compile, add a reference to System.Windows.Forms.dll, System.Data.dll, System.Data.SqlServerCe.dll, and System.Xml.dll.
sddgsort Sorts a DataGrid.
smartdevices\pinvoke
sdconvertbyte Accesses an IntPtr which corresponds to a byte array.
sdmemory Displays memory information about the device.
sdtime Accesses the system clock to get the time and to advance an hour.
sdsound Uses platform invoke to play a sound.
sdreset Resets (soft reboot) the device using platform invoke.
smartdevices\windowsforms\controls
sdbuttonimg Creates a button with an image custom control.
sdsip Shows how to implement the SIP (soft input panel) using the InputPanel component.
sddoclist Shows how you can use a DocumentList control.
sdlinklab Describes how to use the LinkLabel control in the .NET Compact Framework.
sdnotify Shows how to send a notification to a user using the Notification control and how to respond to it. Requires .NET Compact Framework 2.0.
sdim Sets the Pocket PC input method to Letter Recognizer. Requires .NET Compact Framework 2.0.
smartdevices\windowsforms\drawing
sdcopybmp Copies a bitmap and part of a bitmap.
sdtranspar Creates an image with transparency based on the upper left pixel of the image.
sdlogfont Displays text at a 90 degree angle using a LogFont. Requires .NET Compact Framework 2.0.
sdbox Draws a rectangle around a string.
sdoffscrn Shows how reduce flicker by preparing graphics off screen before rendering.
sdgobmp Get a Graphics object from a Bitmap object.
sdgoctl Gets a Graphics object from a control.
sdgopaint Gets the Graphics object from the OnPaint event handler.
sdsaveimg Saves the image of a PictureBox to a file.
sdzoom Zooms an image.
smartdevices\windowsforms\forms
sdcenter Resizes the form to occupy only the center part of the screen.
sdbackimg Displays an image, from an embedded resource, to occupy the size of the form.
sdhidecl Remove close and minimize buttons.
sdhidemb Hides the menu bar below the form.
sdresizef Configures form to be resizable on a Pocket PC.
sdresizec Resizes the length of a ListBox when the SIP (Soft Input Panel) is displayed.
sdscroll Uses scrollbars to scroll through a form with a panel of controls.
sdhard Demonstrates how to override Pocket PC hardware buttons. Requires .NET Compact Framework 2.0.
sdokclose Sets the Close button (OK), to close the form.
sdxclose Sets the Minimize button (X), to minimize the form.
sdfull Makes the form full sized with no menu or title bar.
sdoreint Sets the screen orientation to portrait: 90 degrees. Requires .NET Compact Framework 2.0.
Windowsforms\Clipboard
clipCopyClass Copies an instance of a serializable class to the Clipboard. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
clipCopyImage Copies an Image to the clipboard. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
clipCopyString Copies a String to the Clipboard. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
clipGetImage Gets an Image from the Clipboard and stores it in an Image object. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
clipGetString Gets a string from the Clipboard and stores it in a string variable. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls
controlTip Adds a ToolTip to a Windows Forms Control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\Button
butWidth Resizes a button by measuring its text and then resetting its Width. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
butAutoSize Uses AutoSize to dynamically resize a button to the length of its text. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
Windowsforms\Controls\Calendar
calRange Selects a range of dates in a MonthCalendar control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\ComboBox
cbArrayList Uses an ArrayList object as the data source for a ComboBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
cbData Fills a ComboBox with data from a DataTable object. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
cbComplete Provides automatic text completion for a combobox. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\DatagridView
gridLock Locks the column widths of a DataGridView. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\ListBox
lbClear Clears items from a bound ListBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
lbData Fills a ListBox with data from a DataTable object. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
lbLocate Locates the first incidence of a string in a ListBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
lbSelect Selects an item in a ListBox control, programmatically. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\ListView
lvSelected Determines the selected item in a ListView and assigns it to a variable. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\Menu
menuAddCheck Adds a check mark to a ToolStripMenuItem. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
menuContext Adds a context menu to your form. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
menuAddShort Add a shortcut to a ToolStripMenuItem. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
menuAddItems Adds menu items to an existing menu. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
menuDelete Deletes a ToolStripMenuItem from an existing MenuStrip. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\ProgressBar
pbIterate Increments a ProgressBar by a fixed amount, upon each iteration. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\RadioButton
rbString Creates a group of RadioButtons from a string array. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\RichTextBox
richFormat Adds the text "This text is in bold." to an existing RichTextBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
richLoad Loads a file in RTF format into a RichTextBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
richCursor Positions the cursor in a RichTextBox. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
richSave Saves the content of the RichText box to a RTF file. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\StatusStrip
bartime Displays the time in a StatusStrip.
Windowsforms\Controls\TextBox
tbArray Enters a multiline string into a multiline textbox. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Controls\TreeView
tvSelect Determines the selected node in a TreeView control and assigns it to a variable. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
Windowsforms\Drawing
drawBitmap Creates and fills a Bitmap object and displays it in an existing Windows Forms PictureBox control. For this code snippet to compile, add a reference to System.Windows.Forms.dll.
drawCustBrush Creates a TextureBrush object with an image file. For this code snippet to compile, add a reference to System.Drawing.dll.
drawPen Creates a Pen object. For this code snippet to compile, add a reference to System.Drawing.dll.
drawBrush Creates a SolidBrush object. For this code snippet to compile, add a reference to System.Drawing.dll.
drawTri Draws a triangle by connecting a series of points. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawGif Displays an animated GIF. For this code snippet to compile, add a reference to System.Drawing.dll.
drawEll Draws a filled ellipse on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawRect Draws a filled rectangle on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawLine Draws a line on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawPie Draws a pie chart. For this code snippet to compile, add a reference to System.Drawing.dll.
drawBand Draws a rubber band rectangle on the form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawGrad Draws a shape with gradient fill. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawOutEll Draws outlined ellipses on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawOutRect Draws outlined rectangle on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawText Draws text on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
drawVertText Draws text on a form in a vertical orientation. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
Windowsforms\Fonts
fontCreate Uses three overloads of the Font constructor. For this code snippet to compile, add a reference to System.Drawing.dll.
Windowsforms\Forms
formAdd Creates a new instance of a Windows forms TextBox control at run time. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
mdiArrange Arranges the child forms in a cascading layout. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formMouse Converts mouse coordinates from a mouse event into screen coordinates. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
mdiNew Creates and displays a new MDI child form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formTrans Sets the opacity of a form to make it slightly transparent. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
mdiActive Retrieves the active MDI child form and copies the text from a control on it to the Clipboard. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formSelect Finds the selected control on a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formKey Monitors for modifier keys such as the SHIFT, ALT, and CTRL keys. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formNew Displays a windows form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formTitle Eliminates the TitleBar. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formTop Shows how the TopMost property controls whether a form is a top-most form. A top-most form will float above other, non–top-most forms even when it is not active.
formDrag Shows how to move a form by dragging any part of it with the mouse. This feature is particularly useful when the form has no title bar. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formBeep Plays a beep.
formResize Resizes a form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formRestrict Overrides the default ProcessCmdKey function of a Windows Forms ComboBox control and restricts user input to numeric and navigation keys. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formBox Retrieves information from the parent MDI form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formDlg Determines how a dialog box was closed. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
formLoc Sets the location, in pixels, of the the top-left corner of the form. For this code snippet to compile, add a reference to System.Windows.Forms.dll and System.Drawing.dll.
Windowsforms\Sound
sndLoop Plays a looping sound in the background.
sndPlay Plays a sound from a file.
sndStop Stops a sound playing in the background.
xml
xmlAdd Adds a new Keyword element to the XML. For this code snippet to compile, add a reference to System.XML.dll.
xmlEnum Displays all the attributes by name and value of an XmlNode. For this code snippet to compile, add a reference to System.XML.dll.
xmlFind Locates an element in an XML file by Element name. For this code snippet to compile, add a reference to System.XML.dll.
xmlInfer Infers a Schema from an XML file. For this code snippet to compile, add a reference to System.XML.dll.
xmlIter Iterates the elements in an XML document by element name. For this code snippet to compile, add a reference to System.XML.dll.
xmlNavDoc Iterates through the nodes of an XML document using the XPathNavigator. For this code snippet to compile, add a reference to System.XML.dll.
xmlReadClass Reads class data that was previously written to an XML file using the XmlSerializer class. For this code snippet to compile, add a reference to System.XML.dll.
xmlReadText Uses the XMLTextReader class to extract the element names and text strings from an XML file. For this code snippet to compile, add a reference to System.XML.dll.
xmlReadString Reads XML data from a string.
xmlReadUrl Read XML data from a location defined as an URL. For this code snippet to compile, add a reference to System.XML.dll.
xmlNavNodes Creates an iterator to walkthrough selected nodes. For this code snippet to compile, add a reference to System.XML.dll.
xmlXsl Transforms XML to HTML using a XSL stylesheet. For this code snippet to compile, add a reference to System.XML.dll.
xmlXslt Transforms XML using XSLT into HTML. For this code snippet to compile, add a reference to System.XML.dll.
xmlWriteClass Writes the data from a class to an XML file using the XmlSerializer class. For this code snippet to compile, add a reference to System.XML.dll.