Tag Archives: controls

Make a TextBox with auto-complete in C#

It’s not too hard to make a TextBox provide an auto-complete feature. In fact, the TextBox control offers three auto-complete styles. This example demonstrates those styles. To provide auto-complete, you need to set the following three TextBox properties. AutoCompleteMode – … Continue reading

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

Use the Filter property to select image files in C#

This example is mostly intended to make it easier to find these filters. I use them a lot and it’s a pain to have to recreate them every time I need them. When you click the Different Types button, the … Continue reading

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

Move and resize multiple rectangles in WPF and C#

The example Let the user move and resize a rectangle in WPF and C# shows how to let the user move and resize a single rectangle in a WPF program. This example extends that one to let you move and … Continue reading

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

Display database records without data binding in C#

Many programs use data binding to display database records. That method is easy (at least as far as the code you write is concerned), but it’s not very flexible. This example shows how you can display database records without data … Continue reading

Posted in controls, database, lists, user interface | Tagged , , , , , , , , , , , , , | 1 Comment

Initialize lists from databases without binding in C#

Note that this is a very manual way to initialize lists. Often you can display data more easily by using data binding. In this example, I added the Access database file Books.mdb to the project and set its “Copy to … Continue reading

Posted in controls, database, lists, user interface | Tagged , , , , , , , , , , , , | 1 Comment

Check a TreeView subtree in C#

Sometimes it’s useful to let the user select a TreeView subtree by clicking on a higher-level node. Then the user can deselect individual nodes within the subtree if desired. For example, in the picture shown here I checked the Dinner … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , , , , | 4 Comments

Display context menus for TreeView items in C#

This example displays different context menus when you right-click on different kinds of nodes in a TreeView control. In this example, different nodes represent factories, groups, or individuals. Different node types display different context menus. When it starts, the program … Continue reading

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

Enumerate TreeView nodes in C#

The previous two posts show two ways you can enumerate TreeView nodes that are checked. The idea is to recursively crawl over the tree’s nodes and pick out the checked ones. Unfortunately that method isn’t easily extendable. For example, if … Continue reading

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

Yield checked TreeView nodes in C#

The previous example used recursion to traverse the nodes in a TreeView control and fill a list with the nodes that are checked. This example uses a slightly different approach. It traverses the TreeView control’s nodes and uses the yield … Continue reading

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

Make a list of checked TreeView nodes in C#

If you set a TreeView control’s CheckBoxes property to true, then the control displays boxes that the user can check to select nodes. In that case you will probably need to find the checked TreeView nodes at some point. Strangely … Continue reading

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