Category Archives: controls

Use a Dictionary to store and retrieve items in C#

This example demonstrates a Dictionary. A Dictionary is basically a strongly typed Hashtable. A Hashtable stores key/value pairs in a way that makes looking up values extremely fast. For example, suppose you have an employee database that uses EmployeeId values … Continue reading

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

Explore the Visual Studio Image Library in C#

This example explains where you can find standard images in the Visual Studio Image Library that you can use in your applications. The example Give transparent backgrounds to images displayed on buttons in C# explains how to make some pixels … Continue reading

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

List controls on a form in C#

There are several ways you can list controls on a form. At design time, you can open the form and then use the dropdown at the top of the Properties window. You can also look inside the file Form1.Designer.cs. At … Continue reading

Posted in controls, forms, system | Tagged , , , , , , , , , | Leave a comment

Give transparent backgrounds to images displayed on buttons in C#

This example shows how to give transparent backgrounds to the images displayed on a button. If you give buttons images that have transparent backgrounds, then the button’s background can show through. If the images don’t have transparent backgrounds, the result … Continue reading

Posted in controls, graphics, image processing | Tagged , , , , , , , , , , , | Leave a comment

Make a TextBox convert text into proper case in C#

The example Convert a string to proper case (title case) in C# uses a CultureInfo object’s TextInfo property to convert text into proper case (or title case). There are a couple of tricks and potential problems that you need to … Continue reading

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

Make TextBoxes automatically convert case in C#

It’s actually quite easy to make a TextBox convert case in .NET. Simply set the TextBox control’s CharacterCasing property to Lower or Upper. Then the control automatically converts alphabetic characters into the correct case. You can do this at design … Continue reading

Posted in controls, strings, user interface | Tagged , , , , , , , , , , , , | Leave a comment

Sort ListView controls by all columns or clicked columns in C#

The ListView control provides features to sort its values but by default it doesn’t use them. This example shows how you can add extension methods to the control to make it sort on all columns or on clicked columns. This … Continue reading

Posted in controls, extension methods | Tagged , , , , , , , , , , , , | 1 Comment

Display thumbnails for image files in a directory in C#

This example shows how to display thumbnails for the images in a directory. It displays a tooltip when the mouse hovers over a picture and it opens the image file in the default application if you double-click on an image. … Continue reading

Posted in controls, graphics, image processing | Tagged , , , , , , , , , , , , | Leave a comment

Display tooltips for ListView items in C#

This example shows how to display different tooltips for the items in a ListBox. When you move the mouse over an item in the ListBox, the program uses the following code to display a tooltip for it. // Display a … Continue reading

Posted in controls | Tagged , , , , , , , , , , , , | 1 Comment

Override WndProc to see when the user clicks any control on a form in C#

A form’s WndProc method processes messages sent to the form by the Windows operating system. This is an extremely important method that allows forms to move, resize, repaint, and perform other critical operations. While you normally don’t need to change … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , | Leave a comment