Author Archives: Rod Stephens

Display tips in a status bar instead of a tooltip in C#

A tooltip provides information when a user needs it but remains unobtrusive when the user doesn’t need the information. For example, normally you can chug through a form filling in fields such as Name, Street, City, and State without any … Continue reading

Posted in controls, tips, user interface | Tagged , , , , , , , , , , , , | 2 Comments

Make a status strip label that sticks to the right side of the form in C#

To create a status strip label, add a StatusStrip control to the form. When you select the StatusStrip, it should display an icon with a dropdown arrow. Click the arrow and select the kind of control you want to add … Continue reading

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

Parse file sizes in KB, MB, GB, and so forth in C#

The example Format file sizes in KB, MB, GB, and so forth in C# shows how to convert a number into a string formatted in KB, MB, etc. This example does the opposite: it parses a value such as “1.23 … Continue reading

Posted in algorithms, files, mathematics | Tagged , , , , , , , , , | Leave a comment

Highlight the DataGridView row that is under the mouse in C#

Someone recently asked me how to change the style of the row under the mouse in a DataGridView control. This example does that. When the program starts, the following code prepares the DataGridView for use. // The style to use … Continue reading

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

Use accelerators on labels and buttons in C#

To place an accelerator on a menu item, you put an ampersand in front of the letter in the menu item’s caption that you want to be the accelerator. At run time, the caption is displayed with the accelerator letter … Continue reading

Posted in miscellany, productivity | Tagged , , , , , , , , , , , | Leave a comment

Compare the performance of incrementing statements in C#

This is another performance testing post. Assembly language usually has statements comparable to x++, x–, x +=, and other operators that add or subtract to a value and store the result in the same value, so it makes some sense … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , | Leave a comment

Make a simple event logger in C#

Usually the debugger lets you examine how a program works quite effectively, but sometimes it’s useful to use an event logger to record events for later study. For example, when you’re working with mouse events, stopping execution at a break … Continue reading

Posted in classes, debugging, files | Tagged , , , , , , , , , , | Leave a comment

Make a shaded ellipse control in C#

Note: Before you can use the ShadedEllipse control in the example program, you must build the solution. After you download the example, build it before you try to view the form. This example walks through building a control that draws … Continue reading

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

Quickly insert standard menu items on a form in C#

Many applications need standard File, Edit, Tools, and Help menus. Visual Studio provides a simple way to build standard menu items. You can then edit the menu to add new items and remove items that you don’t need. Visual Studio … Continue reading

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

Give a class default indexer properties in C#

An indexer property is a property that other code can use inside square brackets to access some value provided by the class, much as you can use the index of an array. Unlike an array, a class’s indexer need not … Continue reading

Posted in arrays, classes, syntax | Tagged , , , , , , , , , | Leave a comment