Monthly Archives: June 2016

Show compound interest graphically in C#

This is a more graphic version of the example Calculate the value of a monthly investment in C#. Instead of adding values to a ListView control, this example saves points in three lists of points: Balance, Contributions, and Interest. It … Continue reading

Posted in algorithms, calculations, graphics, mathematics | Tagged , , , , , , , , , , , | 1 Comment

Calculate the value of a monthly investment in C#

The magic of an investment with compound interest is that, over time, you get interest on the interest. For each month this program calculates the interest on the account balance. It then adds the interest and a monthly contribution to … Continue reading

Posted in algorithms, calculations, finance, mathematics | Tagged , , , , , , , , , , , | 2 Comments

Split image files in C#

This example shows how you can split image files into smaller pieces. Recently I needed separate bitmap files for the icons in the Visual Studio toolbox. I took a screen shot and then, rather than splitting the icons apart manually, … Continue reading

Posted in graphics, image processing | Tagged , , , , , , , , | 5 Comments

Use a string collection setting in C#

A program’s settings can include many data types such as int, char, DateTime, and Color. If you want to be able to hold a list of strings, you can make a setting that has type StringCollection. To create such a … Continue reading

Posted in settings | Tagged , , , , , , , , , | 1 Comment

Select and print multiple files in C#

This example lets you easily print multiple files. You can use it, for example, to print all of the .cs files in a project’s directory. Select a printer from the ComboBox at the top. Enter or select a directory and … Continue reading

Posted in files, printers, printing, system | Tagged , , , , , , , , , , , , | 11 Comments

Display the number of checked items in a CheckedListBox in C#

The CheckedListBox control has a CheckedItems collection that holds references to the control’s currently checked items. You can use the collection’s Count property to determine the number of items checked. When the user checks or unchecks an item, the control … Continue reading

Posted in controls, lists | Tagged , , , , , , , , , , , | Leave a comment

Set a print job name in C#

By default, when you send a PrintDocument to a printer, the printer spool shows the job’s name as “document.” You can change the print job name by setting the PrintDocument object’s DocumentName property. This example uses the following code to … Continue reading

Posted in printers, printing, system | Tagged , , , , , , , , , , , , , | 1 Comment

Determine the default printer in C#

When this example starts, the following code lists the printers and selects the default printer. private void Form1_Load(object sender, EventArgs e) { // Find all of the installed printers. foreach (string printer in PrinterSettings.InstalledPrinters) { cboPrinter.Items.Add(printer); } // Find and … Continue reading

Posted in printing, system | Tagged , , , , , , , , , | 3 Comments

See how much text fits in a rectangle in C#

This program determines how much text fits in the left PictureBox and draws it. It then draws the remaining text in the right PictureBox. If you change the form’s size, the size of the PictureBox controls change so how much … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , , , , , , , , , | Leave a comment

Print a text file in C#

This example lets you select a printer and file, and then print the file on the selected printer. (Actually this version just displays a print preview. To send the file directly to the selected printer, see the example Send a … Continue reading

Posted in printers, printing, system | Tagged , , , , , , , , , , , , , , , , , | 2 Comments