Tag Archives: button

Make transparent button images in C#

It seems like I keep writing this program because I need to make button images fairly often. I wanted to use a simple image with a transparent background for a button image. Unfortunately MSPaint doesn’t know how to save images … Continue reading

Posted in controls, drawing, graphics | 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

Perform multiple default actions in C#

Occasionally (but not often!) it’s useful to let a form perform multiple default actions depending on the part of the form that the user is currently using. This example displays the message “Name updated” if you press Enter while updating … Continue reading

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

Perform a default action without an accept button in C#

Normally to give a form a default action, you set the form’s AcceptButton property to a button that should be triggered when the user presses Enter. But what if you don’t want a visible button on the form? You can … Continue reading

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

Flush click events in C#

If a button starts a long task, you probably don’t want the user to be able to click the button again (or perhaps not anything in the application) until the task finishes. The following code shows a straightforward attempt to … Continue reading

Posted in API, controls, events, syntax, system, threading | Tagged , , , , , , , , , , , , , | 12 Comments

Draw an ellipse that sort of looks like a button in C#

This example uses two LinearGradientBrushes to draw an ellipse that has a sort of three-dimensional button-like appearance. The key is to outline the ellipse and then fill it with brushes whose gradients point in opposite directions. The following code shows … Continue reading

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

Make a shaped button in C#

This example shows how to make a shaped button in a Windows Forms C# project. It uses the following Load event handler to confine a Button control to a region to give it a non-rectangular shape. // Shape the button. … Continue reading

Posted in controls | Tagged , , , , , , , , , , , | 12 Comments