Windows Forms Button (SfButton) Overview

30 Jan 20233 minutes to read

The SfButton is an advanced button control capable of displaying text and image with various customizations. It provide options to customize the text, image, border, and appearance in all states of the button.

Key Features

Following are the key features of the SfButton:

  • Appearance: Supports customizing the appearance in all button states (hover, pressed, focused, and disabled states).

  • Image: Supports customizing the image in all button states.

  • Background image: Supports displaying the image in the background of the button.

  • Rich text: Supports displaying the rich text inside the SfButton.

  • Wrap text and trimming: Supports wrapping and trimming the button text.

  • AutoSize: Supports adjusting the size of the button based on the content.

Choose between different button controls

Syncfusion WinForms suite comes up with the following different buttons:

SfButton

SfButton is an advanced button control capable of displaying text and image with various customizations. This provides options to customize the text, image, border, and appearance in all states of the button.

ButtonAdv

ButtonAdv is an advanced button control capable of displaying images with different alignments and various border styles. This can be configured in any predefined ButtonTypes such as Calculator, Up, Down, and so on. This can also afford XP or Office style.

ButtonEdit

The Button Edit control embeds a text box control with collection of button controls that can be customized to create many commonly used interfaces such as file or folder browser or drop-down text control. You can also implement file picker and folder browser.

ToggleButton

The ToggleButton control allows you to toggle between two states (active and inactive) opposite to each other in terms of behavior.

SplitButton

The SplitButton control allows you to create drop-down button-like interface that is a combination of regular button and drop-down list. You can use this control when you need a single control with multiple options. For example, you can use this control to create a button to set font and list available in the font family of drop-down list.

SfButton vs ButtonAdv

Both SfButton and ButtonAdv controls are used for same purposes. But, the SfButton control offers rich set of features over ButtonAdv. To customize the appearance of all button states, use the SfButton control. To use the predefined button types such as Calculator, Up, Down, and so on, use the ButtonAdv control. Comparatively, the performance of SfButton control is better than ButtonAdv control.

You can see some of the specific API differences between ButtonAdv and SfButton as follows.

SfButton

ButtonAdv

Description

Text Text Displays the text in the button.
Image Image Displays the image in the button.
BackgroundImage BackgroundImage Sets the background image to the button.
TextImageRelation TextImageRelation Sets the position of image and text.
TextAlign TextAlign Sets the alignment of text inside the button.
ImageAlign ImageAlign Sets the alignment of image into the button.
FocusRectangleVisible KeepFocusRectangle Draws a thin dotted rectangular frame inside the button when it got focus.
Border BorderStyleAdv Draws the border around the button.
ThemeName Appearance Applies visual styles for button.

The following list of features are in SfButton over ButtonAdv.

Feature

Description

Appearance customization Changes the

appearance

such as back color, fore color, border, and image in all button states (hover, pressed, focus and disable states).
Animation image Loads the

GIF

image.
Rich text Displays the rich text inside SfButton by enabling the

AllowRichText

property. This can be added to the

Text

property.
Spacing between image and text Adjusts space between image and text. Refer to

here

for details.
Wrap Text Wraps the text by using the

WrapText

property in SfButton.
Text Trimming Trims the text by using the

AllowEllipse

property.