SimpleButton.Text Property
Gets or sets the text string displayed within the button control.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v18.2.dll
Declaration
[DXCategory("Appearance")]
[Browsable(true)]
[SmartTagProperty("Text", "Appearance", 0, SmartTagActionType.RefreshBoundsAfterExecute)]
public override string Text { get; set; }
Property Value
Type | Description |
---|---|
String | A string value representing the button’s caption. |
Remarks
Changing this property’s value at runtime raises the TextChanged event.
The button’s text is not displayed if the SimpleButton.ImageLocation property is set to MiddleCenter and an image is assigned to the button via the SimpleButton.ImageIndex or SimpleButton.Image properties. In this instance, only the image centered within the button is displayed.
If the SimpleButton.AllowHtmlDraw property is set to true, you can use HTML tags to format the SimpleButton.Text. For detailed information see HTML Text Formatting.
Example
The following sample code declares a CreateSimpleButton method that creates and initializes a new SimpleButton control. The method has two parameters specifying the coordinates of the button’s top left corner. The BaseButton.CalcBestFit method is used to calculate the size of the button’s contents (an image and text) in order to set a proper button size.
The result of the sample code execution is displayed below.
using DevExpress.XtraEditors;
// ...
private void CreateSimpleButton(int left, int top){
// Creating and initializing a new SimpleButton control
SimpleButton simpleButton = new SimpleButton();
Controls.Add(simpleButton);
simpleButton.Text = "Show Settings Page";
simpleButton.ImageList = imageList1;
simpleButton.ImageIndex = 0;
simpleButton.Size = simpleButton.CalcBestFit(simpleButton.CreateGraphics());
simpleButton.Location = new Point(left, top);
}
// Creating SimpleButton control at the specific location
CreateSimpleButton(30, 30);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Text property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.