Class RadButtonElement
Represents a button element. The button element could be placed in each control's Items collection. It encapsulates all the necessary logic related to the user interaction and UI. The RadButton class is a simple wrapper for the RadButtonElement class. The RadButton acts to transfer events to and from its corresponding RadButtonElement instance. The RadButtonElement which is essentially the RadButton control may be nested in other telerik controls.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.UI.dll
Syntax
[ComVisible(false)]
public class RadButtonElement : RadButtonItem, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IComponent, IDisposable, IBindableComponent, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode, IButtonControl, IImageElement
Constructors
RadButtonElement()
Initializes a new instance of the RadButtonElement class.
Declaration
public RadButtonElement()
RadButtonElement(String)
Initializes a new instance of the RadButtonElement class with the specified text.
Declaration
public RadButtonElement(string text)
Parameters
System.String
text
The text to display on the button element. |
RadButtonElement(String, Image)
Initializes a new instance of the RadButtonElement class with the specified text and image.
Declaration
public RadButtonElement(string text, Image image)
Parameters
System.String
text
The text to display on the button element. |
System.Drawing.Image
image
The image to display on the button element. |
Fields
LargeImageIndexProperty
Identifies the LargeImageIndex property.
Declaration
public static RadProperty LargeImageIndexProperty
Field Value
RadProperty
|
LargeImageKeyProperty
Identifies the LargeImageKey property.
Declaration
public static RadProperty LargeImageKeyProperty
Field Value
RadProperty
|
LargeImageProperty
Identifies the LargeImage property.
Declaration
public static RadProperty LargeImageProperty
Field Value
RadProperty
|
SmallImageIndexProperty
Identifies the SmallImageIndex property.
Declaration
public static RadProperty SmallImageIndexProperty
Field Value
RadProperty
|
SmallImageKeyProperty
Identifies the SmallImageKey property.
Declaration
public static RadProperty SmallImageKeyProperty
Field Value
RadProperty
|
SmallImageProperty
Identifies the SmallImage property.
Declaration
public static RadProperty SmallImageProperty
Field Value
RadProperty
|
UseSmallImageListProperty
Identifies the UseSmallImageList property.
Declaration
public static RadProperty UseSmallImageListProperty
Field Value
RadProperty
|
Properties
BorderElement
Gets or sets the BorderPrimitive element that is responsible for painting the border of the button control.
Declaration
public BorderPrimitive BorderElement { get; protected set; }
Property Value
BorderPrimitive
|
ButtonFillElement
Gets or sets the FillPrimitive element that is responsible for painting the background of the button control.
Declaration
public FillPrimitive ButtonFillElement { get; protected set; }
Property Value
FillPrimitive
|
FocusPrimitive
Gets a reference to the FocusPrimitive element that handles focus indication for the RadButtonElement.
Declaration
public FocusPrimitive FocusPrimitive { get; }
Property Value
FocusPrimitive
|
ImagePrimitive
Gets or sets a reference to the ImagePrimitive element that handles image rendering for the RadButtonElement.
Declaration
public ImagePrimitive ImagePrimitive { get; protected set; }
Property Value
ImagePrimitive
|
ImagePrimitiveAngleTransform
Gets or sets the angle of rotation for the button image in degrees. Unlike AngleTransform, the ImagePrimitiveAngleTransform property rotates only the image element, not the entire button.
Declaration
[RadDefaultValue("AngleTransform", typeof(ImagePrimitive))]
public float ImagePrimitiveAngleTransform { get; set; }
Property Value
System.Single
|
IsCancelClicked
Gets or sets a value indicating whether the button click operation was canceled. This property is used internally by the framework to track click cancellation state. This property is used internally!
Declaration
public bool IsCancelClicked { get; set; }
Property Value
System.Boolean
|
LargeImage
Gets the large image that is displayed on the button element. This property is read-only and retrieves the image from the associated ImageList.
Declaration
[RadPropertyDefaultValue("LargeImage", typeof(RadButtonElement))]
public virtual Image LargeImage { get; }
Property Value
System.Drawing.Image
|
LargeImageIndex
Gets the large image list index value of the image displayed on the button control. This property is read-only and represents the index in the associated large ImageList.
Declaration
[RadPropertyDefaultValue("LargeImageIndex", typeof(RadButtonElement))]
public virtual int LargeImageIndex { get; }
Property Value
System.Int32
|
LargeImageKey
Gets the large key accessor for the image in the ImageList. This property is read-only and represents the string key used to identify the image in the associated large ImageList.
Declaration
[RadPropertyDefaultValue("LargeImageKey", typeof(RadButtonElement))]
public virtual string LargeImageKey { get; }
Property Value
System.String
|
LayoutPanel
Gets or sets a reference to the ImageAndTextLayoutPanel that manages the layout and positioning of image and text elements within the button.
Declaration
public ImageAndTextLayoutPanel LayoutPanel { get; protected set; }
Property Value
ImageAndTextLayoutPanel
|
MeasureTrailingSpaces
Gets or sets a value indicating whether trailing spaces at the end of each line should be included in text measurement. By default, the Graphics.MeasureString method excludes trailing spaces. Setting this to true includes that space in measurement calculations.
Declaration
public bool MeasureTrailingSpaces { get; set; }
Property Value
System.Boolean
|
ShowBorder
Gets or sets a value indicating whether the border is visible around the button. When true, the border is displayed; when false, the border is collapsed and not visible.
Declaration
public bool ShowBorder { get; set; }
Property Value
System.Boolean
|
SmallImage
Gets or sets the small image that is displayed on the button element. This property allows direct assignment of an Image object to be displayed.
Declaration
[RadPropertyDefaultValue("SmallImage", typeof(RadButtonElement))]
public virtual Image SmallImage { get; set; }
Property Value
System.Drawing.Image
|
SmallImageIndex
Gets or sets the small image list index value of the image displayed on the button control. This property specifies the index of the image in the associated small ImageList.
Declaration
[RadPropertyDefaultValue("SmallImageIndex", typeof(RadButtonElement))]
public virtual int SmallImageIndex { get; set; }
Property Value
System.Int32
|
SmallImageKey
Gets or sets the small key accessor for the image in the ImageList. This property specifies the string key used to identify the image in the associated small ImageList.
Declaration
[RadPropertyDefaultValue("SmallImageKey", typeof(RadButtonElement))]
public virtual string SmallImageKey { get; set; }
Property Value
System.String
|
TextElement
Gets or sets the TextPrimitive element that is responsible for rendering the text content of the button control.
Declaration
public TextPrimitive TextElement { get; protected set; }
Property Value
TextPrimitive
|
TextWrap
Gets or sets a value indicating whether the text should wrap to the available layout rectangle. When true, text will wrap to multiple lines within the button's bounds; when false, text remains on a single line.
Declaration
[RadPropertyDefaultValue("TextWrap", typeof(TextPrimitive))]
public bool TextWrap { get; set; }
Property Value
System.Boolean
|
UseSmallImageList
Gets or sets a value indicating whether the button should use the small image list instead of the original image list. When set to true, images are retrieved from the SmallImageList; when false, images are retrieved from the standard ImageList.
Declaration
public virtual bool UseSmallImageList { get; set; }
Property Value
System.Boolean
|
Methods
CreateChildElements()
Creates the child elements that compose the button structure including fill, border, text, image, layout panel, and focus primitives. This method establishes the visual hierarchy and property bindings between the child elements.
Declaration
protected override void CreateChildElements()
Overrides
GetVistaVisualStyle()
Gets the appropriate VisualStyleElement based on the current button state.
Declaration
public override VisualStyleElement GetVistaVisualStyle()
Returns
System.Windows.Forms.VisualStyles.VisualStyleElement
A VisualStyleElement that represents the current visual state of the button. |
Overrides
GetXPVisualStyle()
Declaration
public override VisualStyleElement GetXPVisualStyle()
Returns
System.Windows.Forms.VisualStyles.VisualStyleElement
|
Overrides
InitializeFields()
Initializes the fields of the RadButtonElement.
Declaration
protected override void InitializeFields()
Overrides
InitializeSystemSkinPaint()
Initializes system skin painting by updating text color to match system theme requirements. This method configures the text primitive's foreground color based on the current system skin manager settings.
Declaration
protected override void InitializeSystemSkinPaint()
Overrides
MeasureButtonChildren(SizeF)
Measures the child elements of the button and calculates the total required size based on AutoSize behavior and layout constraints.
Declaration
protected SizeF MeasureButtonChildren(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
The available space for measuring child elements. |
Returns
System.Drawing.SizeF
The calculated size required to accommodate all child elements within the specified constraints. |
MeasureOverride(SizeF)
Measures the desired size of the button element within the given available space constraints.
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
The available space that the button element can occupy. |
Returns
System.Drawing.SizeF
The desired size of the button element. |
Overrides
OnClick(EventArgs)
Handles the click event for the button element. This method ensures only left mouse button clicks are processed.
Declaration
protected override void OnClick(EventArgs e)
Parameters
System.EventArgs
e
The event arguments containing information about the click event. |
Overrides
ShouldPaintChild(RadElement)
Determines whether a specific child element should be painted when system skin rendering is enabled.
Declaration
protected override bool ShouldPaintChild(RadElement element)
Parameters
RadElement
element
The child element to evaluate for painting. |
Returns
System.Boolean
True if the element should be painted; false if it should be skipped during the paint operation. |