HypernovaDesktop Components · docs
Binarymission
WinFormsSmart Button › SmartButton

SmartButton

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.ButtonControls

BinarySmartButton .NET control is an extended and feature-rich replacement for the standard .NET Framework Button control.

public class SmartButton : System.Windows.Forms.Control, IButtonControl

Inherits from / implements: System.Windows.Forms.Control, IButtonControl

Remarks

BinarySmartButton .NET offers the following rich features:

1. "XP-theme" style UI: The control presents its UI with the XP theme style look.

2. Support for displaying icon images with Alpha-channel information: You can now set button images with Icons without losing its alpha-channel information.
The standard .NET button control does not directly support displaying Icons with alpha-channel. Moreover, .NET standard button control does not display images when its FlatStyle is set to "System" in order to enable themed look.
BinarySmartButton presents its UI with XP themed look, also displaying icon images without losing the icon's alpha-channel information.

3. Menu Button style: The control supports a special MenuButton style. When set with this style, you can assign a set of MenuItems to the control, and the control will automatically display a drop-down menu just below the control so as to let your users choose a command from a list of numerous possible commands. This feature extends the button control's functionality by making a variety of commands to choose from and execute, instead of the traditional "one command" button functionality.
The control's drop-down menu can be displayed using our popular BinaryMenuItem .NET control that comes with this .NET assembly. This menu control lets you display Images and text in the drop-down menu along with the ever popular "Visual Studio .NET" style menu.
Alternatively, you could also simply use the standard MenuItem object to display the drop-down menu.
Either way, all you need to do is to set the ButtonStyle to MenuButton style and set the DropDownMenuItems property to array of your defined BinaryMenuItem .NET control or MenuItem objects.
Please refer to the detailed C# .NET sample demonstration program source code that accompanies the control package, to see how to use the various features of this control.

Members at a glance

SmartButton
BorderColorGets or sets the color of the border.
ButtonStyleGets or sets the button style.
ContextMenuPropertiesGets or sets the user / custom defined settings for drawing the context menu properties.
DefaultThemeGets or sets whether to use the default active theme.
DialogResultImplements IButtonControl.DialogResult property.
DrawFocusRectangleGets or sets whether a focus rectangle needs to be drawn when the button control is in focus.
DrawMenuButtonSeparatorGets or sets a value indicating whether to draw the menu button separator.
DropDownArrowMarkColorGets or sets the color of the drop-down arrow mark image that is displayed at the far right corner of the control, when the control is set to "ButtonStyles.MenuButton" style.
DropDownMenuItemsGets or sets the drop-down menu object of the control.
EndColorGets or sets the end color.
ForeColorGets or sets the control's text forecolor.
IconGets or sets the Icon that is displayed on the control.
ImageGets or sets the Image that is displayed on the control.
IsRenderingThemeGets or sets a value indicating whether the control is rendering one of the built-in themes.
LinearGradientRenderingAngleGets or sets the linear gradient rendering angle.
MenuButtonSeparatorColorGets or sets the color of the menu button separator.
MenuButtonSeparatorLineHeightGets or sets the Menu button separator line height.
PushedEndColorGets or sets the end color for the pushed state of the control.
PushedStartColorGets or sets the start color for the pushed state of the control.
ShowDropDownArrowGets or sets whether to display a drop-down arrow mark when the control is set to "ButtonStyles.MenuButton" style.
StartColorGets or sets the start color.
TextGets or sets the text string that is displayed on the control.
TextStringFormatGets or sets the user defined text string format to use.
TransparentColorGets or sets the transparent color to use, when the Image property is set with a valid Bitmap.
UseCustomDefinedPropertiesForRenderingContextMenuGets or sets a value indicating whether to use custom defined properties for rendering context menu.
UseCustomTextStringFormatGets or sets a value indicating whether to use custom text string format.
UseUserDefinedColorForArrowMarkGets or sets a value indicating whether to use user defined color for Arrow mark..
UseUserDefinedColorForMenuButtonSeparatorGets or sets a value indicating whether to use user defined color for menu button separator.
XPThemeGets or sets the XP theme to emulate while drawing the control.
DisposeOverriden implementation. Kindly refer the base class (Controldocumentation.
NotifyDefaultImplements IButtonControl.NotifyDefault method.
OnClickOverriden implementation. Kindly refer the base class (Controldocumentation.
OnDpiChangedAfterParentRepaints the button when it moves to a display with a different scale factor.
OnEnterOverriden implementation. Kindly refer the base class (Controldocumentation.
OnHandleCreated
OnKeyDownOverriden implementation. Kindly refer the base class (Controldocumentation.
OnKeyUpOverriden implementation. Kindly refer the base class (Controldocumentation.
OnLeaveOverriden implementation. Kindly refer the base class (Controldocumentation.
OnMouseDownOverriden implementation. Kindly refer the base class (Controldocumentation.
OnMouseEnterOverriden implementation. Kindly refer the base class (Controldocumentation.
OnMouseLeaveOverriden implementation. Kindly refer the base class (Controldocumentation.
OnMouseMoveOverriden implementation. Kindly refer the base class (Controldocumentation.
OnMouseUpOverriden implementation. Kindly refer the base class (Controldocumentation.
OnPaintOverridden implementation. Kindly refer the base class (Controldocumentation.
OnParentChangedOverriden implementation. Kindly refer the base class (Controldocumentation.
OnSizeChangedOverriden implementation. Kindly refer the base class (Controldocumentation.
OnSystemColorsChangedRefer to base class documentation.
OnTextChangedOverriden implementation. Kindly refer the base class (Controldocumentation.
PerformClickImplements IButtonControl.PerformClick method.
ProcessMnemonicOverriden implementation. Kindly refer the base class (Controldocumentation.
WndProcProcesses Windows messages.
OnAboutToTheShowContextMenuOnMenuButtonA specialized event that is raised just when the user clicks on the control (when it is of type MenuButton) and the assigned context menu is about to be shown.

Constructors

SmartButton

public SmartButton()

No summary in the source yet.

Properties

BorderColor

public Color BorderColor

Gets or sets the color of the border.

Applicable only when the IsRenderingTheme property is set to false.

ButtonStyle

public ButtonStyles ButtonStyle

Gets or sets the button style.

Set this property with one of the valid styles from the ButtonStyles enumeration.

ContextMenuProperties

public ContextMenuProperties ContextMenuProperties

Gets or sets the user / custom defined settings for drawing the context menu properties.

Value. The context menu properties.

Refer to the deatils of this class here ContextMenuProperties.

DefaultTheme

public bool DefaultTheme

Gets or sets whether to use the default active theme.

If the current Operating System is Windows XP, then setting this property to true will use the current default XP theme as used in the machine. Otherwise, the default XP theme to emulate is taken as Blue theme, unless you have set the XPTheme property value to a particular XP theme value.
The default value is true.

DialogResult

public System.Windows.Forms.DialogResult DialogResult

Implements IButtonControl.DialogResult property.

DrawFocusRectangle

public bool DrawFocusRectangle

Gets or sets whether a focus rectangle needs to be drawn when the button control is in focus.

The default is false.

DrawMenuButtonSeparator

public bool DrawMenuButtonSeparator

Gets or sets a value indicating whether to draw the menu button separator.

Value. true if to draw menu button separator; otherwise, false .

DropDownArrowMarkColor

public Color DropDownArrowMarkColor

Gets or sets the color of the drop-down arrow mark image that is displayed at the far right corner of the control, when the control is set to "ButtonStyles.MenuButton" style.

The default value is ControlText value.

DropDownMenuItems

public MenuItem[] DropDownMenuItems

Gets or sets the drop-down menu object of the control.

When the control is set to "ButtonStyles.MenuButton" style, the control can display a drop-down menu on the control's KeyDown and MouseDown events.
You will need to set this property with an array of MenuItem or BinaryMenuItem .NET control objects. Once set, the control will display a drop-down menu based on the menu items you have set this property with.
Note: This property cannot be set from the VS.NET property editor.
You will have to create an array of either MenuItem or BinaryMenuItem .NET control objects and assign it to this property.
It is advisable to do this in your Form's Load event. For an example, please refer to the sample demonstration code that is installed in the control's installation folder.

EndColor

public Color EndColor

Gets or sets the end color.

Value. The end color.

ForeColor

public new Color ForeColor

Gets or sets the control's text forecolor.

The default value is ControlText value.

Icon

public Icon Icon

Gets or sets the Icon that is displayed on the control.

BinarySmartButton control can display Icon images without losing its alpha-channel information.
This means that you can display 32-bit Icon objects which has the alpha-channel information (for e.g. drop-shadow information).
Only Icon objects are supported for displaying images with the drop-shadow effects (alpha-channel).
Note: When this property is set to a valid Icon object, the Image property is automatically set to null.

Image

public Image Image

Gets or sets the Image that is displayed on the control.

Only Icon objects are supported for displaying the images with drop-shadow effects (alpha-channel).
Note: When this property is set to a valid Image object, the Icon property is automatically set to null.

IsRenderingTheme

public bool IsRenderingTheme

Gets or sets a value indicating whether the control is rendering one of the built-in themes.

LinearGradientRenderingAngle

public float LinearGradientRenderingAngle

Gets or sets the linear gradient rendering angle.

Value. The linear gradient rendering angle.

MenuButtonSeparatorColor

public Color MenuButtonSeparatorColor

Gets or sets the color of the menu button separator.

Value. The color of the menu button separator.

MenuButtonSeparatorLineHeight

public int MenuButtonSeparatorLineHeight

Gets or sets the Menu button separator line height.

By default, the control calculates the optimized height for the line drawing.
If you want to set a custom height for the menu button separator line, you can set this property with a custom value.
Note that the control will not let you set a size beyond a maximum optimum value.
By default, i.e. if the control is to be let to decide on the size, leave this property value at its default value - i.e. -1 .

PushedEndColor

public Color PushedEndColor

Gets or sets the end color for the pushed state of the control.

PushedStartColor

public Color PushedStartColor

Gets or sets the start color for the pushed state of the control.

ShowDropDownArrow

public bool ShowDropDownArrow

Gets or sets whether to display a drop-down arrow mark when the control is set to "ButtonStyles.MenuButton" style.

The default value is true.

StartColor

public Color StartColor

Gets or sets the start color.

Value. The start color.

Text

public override string Text

Gets or sets the text string that is displayed on the control.

TextStringFormat

public StringFormat TextStringFormat

Gets or sets the user defined text string format to use.

Value. The user defined custom text string format (i.e. StringFormat).

TransparentColor

public Color TransparentColor

Gets or sets the transparent color to use, when the Image property is set with a valid Bitmap.

UseCustomDefinedPropertiesForRenderingContextMenu

public bool UseCustomDefinedPropertiesForRenderingContextMenu

Gets or sets a value indicating whether to use custom defined properties for rendering context menu.

Value. true if to use custom defined properties for rendering context menu; otherwise, false .

UseCustomTextStringFormat

public bool UseCustomTextStringFormat

Gets or sets a value indicating whether to use custom text string format.

Value. true if to use custom text string format StringFormat; otherwise, false .

UseUserDefinedColorForArrowMark

public bool UseUserDefinedColorForArrowMark

Gets or sets a value indicating whether to use user defined color for Arrow mark..

Value. true if to use user defined color for Arrow mark; otherwise, false .

UseUserDefinedColorForMenuButtonSeparator

public bool UseUserDefinedColorForMenuButtonSeparator

Gets or sets a value indicating whether to use user defined color for menu button separator.

Value. true if to use user defined color for menu button separator; otherwise, false .

XPTheme

public XPThemes XPTheme

Gets or sets the XP theme to emulate while drawing the control.

Set this property with one of the valid XP themes from the XPThemes enumeration.
The default value is "XPThemes.Blue".

Methods

Dispose

protected override void Dispose(bool disposing)

Overriden implementation. Kindly refer the base class (Controldocumentation.

NotifyDefault

public void NotifyDefault(bool value)

Implements IButtonControl.NotifyDefault method.

OnClick

protected override void OnClick(System.EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnDpiChangedAfterParent

protected override void OnDpiChangedAfterParent(EventArgs e)

Repaints the button when it moves to a display with a different scale factor.

e
The event data.

OnEnter

protected override void OnEnter(System.EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

No summary in the source yet.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs ke)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnKeyUp

protected override void OnKeyUp(KeyEventArgs ke)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnLeave

protected override void OnLeave(System.EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnMouseDown

protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnMouseEnter

protected override void OnMouseEnter(EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnMouseLeave

protected override void OnMouseLeave(EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnMouseMove

protected override void OnMouseMove(MouseEventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnMouseUp

protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnPaint

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)

Overridden implementation. Kindly refer the base class (Controldocumentation.

OnParentChanged

protected override void OnParentChanged(System.EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnSizeChanged

protected override void OnSizeChanged(System.EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

OnSystemColorsChanged

protected override void OnSystemColorsChanged(EventArgs e)

Refer to base class documentation.

e

OnTextChanged

protected override void OnTextChanged(EventArgs e)

Overriden implementation. Kindly refer the base class (Controldocumentation.

PerformClick

public void PerformClick()

Implements IButtonControl.PerformClick method.

ProcessMnemonic

protected override bool ProcessMnemonic(char charCode)

Overriden implementation. Kindly refer the base class (Controldocumentation.

WndProc

protected override void WndProc(ref Message m)

Processes Windows messages.

m
The Windows Message to process.

Events

OnAboutToTheShowContextMenuOnMenuButton

public event AboutToTheShowContextMenuOnMenuButton OnAboutToTheShowContextMenuOnMenuButton

A specialized event that is raised just when the user clicks on the control (when it is of type MenuButton) and the assigned context menu is about to be shown.

Refer to the delegate AboutToTheShowContextMenuOnMenuButton documentation for more details.