Category Archives: dialogs

Use file dialog filters in C#

The OpenFileDialog and SaveFileDialog components have a Filter property that lets the user look for specific kinds of files. The property’s value should be a pipe symbol (|) separated list of alternating filter names and patterns. Each pattern can include … Continue reading

Posted in dialogs, files | Tagged , , , , , , , , , , , , | Leave a comment

Set the MessageBox default button in C#

The fifth parameter to MessageBox.Show indicates the default button. The following code shows how the program displays a MessageBox with the second button as the default so it is initially selected when the message box appears. // Display a message … Continue reading

Posted in dialogs, MessageBox | Tagged , , , , , , , , , | Leave a comment

Display a simple password dialog before a program starts in C#

You might think that a program could start with a password form and then display its main form if the user enters a valid password. Unfortunately when the initial password form closes, it ends the whole application. A better approach … Continue reading

Posted in dialogs, forms, programs | Tagged , , , , , , , , , , | Leave a comment

Display custom colors in the color selection dialog in C#

The color selection dialog can display custom colors in the 16 boxes on its lower left (see the picture). Your code can initialize those colors by setting the dialog’s CustomColors property to an array of integers representing the colors. One … Continue reading

Posted in dialogs, graphics | Tagged , , , , , , , , , , | 1 Comment

Use value equality to compare font objects in C#

This example explains the difference between reference equality and value equality, and shows how you can test value equality for font objects. Reference equality asks whether two variables refer to the same object. In contrast, value equality asks whether two … Continue reading

Posted in dialogs, fonts, OOP, syntax | Tagged , , , , , , , , , , , , , , | Leave a comment

Display a font selection dialog with an Apply button in C#

Sometimes an application displays a font selection dialog that has an Apply button. If you click that button, the application shows what it would look like if you accept the dialog’s current font. If you click OK, the dialog closes … Continue reading

Posted in dialogs, fonts | Tagged , , , , , , , , , | 1 Comment

Make a dialog with standard dialog features in C#

Making a dialog is easy. Just add a new form to the project. Making a dialog that provides standard features (so it acts more or less like a standard dialog) only takes a little more work. To do it right, … Continue reading

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

Use standard dialogs in C#

To use a standard dialog, first place the dialog on a form and set any properties that you want to customize. For example, you may want to set a file dialog’s Filter property to let the user easily filter for … Continue reading

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

Make the user enter a password to use a program in C#

The example Display a simple password dialog before a program starts in C# displays a simple password form. It compares the value entered by the user with a string inside the program to decide whether the user entered the right … Continue reading

Posted in cryptography, dialogs, programs | Leave a comment

Display reusable dialog forms in C#

The example Make a dialog with standard dialog features in C# shows the most common approach to making dialogs. Whenever it needs to display the dialog, the main program initializes a new instance of it and displays it. If the … Continue reading

Posted in dialogs | Leave a comment