Back to Devexpress

SimpleButton.Text Property

windowsforms-devexpress-dot-xtraeditors-dot-simplebutton.md

latest8.5 KB
Original Source

SimpleButton.Text Property

Gets or sets the text string displayed within the button control.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Appearance")]
[Browsable(true)]
public override string Text { get; set; }
vb
<DXCategory("Appearance")>
<Browsable(True)>
Public Overrides Property Text As String

Property Value

TypeDescription
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 button display the image and the SimpleButton.ImageOptions.Location property is set to MiddleCenter.

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 code creates a SimpleButton at a specific location and subscribes to the button’s Click event. The BaseButton.CalcBestFit method is used to calculate the button size that fits the button’s contents.

csharp
using DevExpress.XtraEditors;
// ...
CreateSimpleButton(30, 30);
// ...
private void CreateSimpleButton(int left, int top) {
    SimpleButton simpleButton = new SimpleButton();
    Controls.Add(simpleButton);
    simpleButton.Text = "Show Settings Page";
    simpleButton.ImageOptions.ImageList = imageCollection1;
    simpleButton.ImageOptions.ImageIndex = 0;
    simpleButton.Padding = new Padding(10);
    using(var graphics = simpleButton.CreateGraphics())
        simpleButton.Size = simpleButton.CalcBestFit(graphics);
    simpleButton.Location = new Point(left, top);
    simpleButton.Click += SimpleButton_Click;
}

private void SimpleButton_Click(object sender, EventArgs e) {
    // ...
}
vb
Imports DevExpress.XtraEditors
' ...
CreateSimpleButton(30, 30)
' ...
Private Sub CreateSimpleButton(ByVal left As Integer, ByVal top As Integer)
    Dim simpleButton As New SimpleButton()
    Controls.Add(simpleButton)
    simpleButton.Text = "Show Settings Page"
    simpleButton.ImageOptions.ImageList = ImageCollection1
    simpleButton.ImageOptions.ImageIndex = 0
    simpleButton.Padding = New Padding(10)
    Using graphics = simpleButton.CreateGraphics()
        simpleButton.Size = simpleButton.CalcBestFit(graphics)
    End Using
    simpleButton.Location = New Point(left, top)
    AddHandler simpleButton.Click, AddressOf SimpleButton_Click
End Sub

Private Sub SimpleButton_Click()
    '...
End Sub

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.

winforms-mvvm-best-practices/CS/DelegateCommands/SimpleCommandUserControl.cs#L15

csharp
SimpleButton commandButton = new SimpleButton();
commandButton.Text = "Execute Command";
commandButton.Dock = DockStyle.Top;

winforms-map-convert-a-cartesian-data-shapefile-to-geo-coordinates/CS/MapSample/Form1.cs#L55

csharp
btnSave.Enabled = true;
btnPrj.Text = "2. Projection Loaded automatically";
btnPrj.Enabled = false;

XAF-search-objects-using-complex-criterion/CS/Dennis.Search.Win/SearchObjectPropertyEditor.cs#L31

csharp
btnSearchCore.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
btnSearchCore.Text = Properties.Resources.SearchButtonText;
btnSearchCore.Click += btnSearchCore_Click;

spreadsheet-document-api-use-worksheet-data-bindings-to-process-data/CS/PerformanceCounterCorrelationExample/Form1.cs#L47

csharp
if (!CreateCounters()) return;
btnStart.Text = "Stop";
dataProvider = new PerformanceDataProvider(firstCounter, secondCounter);

winforms-dashboard-custom-properties/CS/WinForms-Dashboard-Custom-Properties/Modules/DashboardDescriptionModule.cs#L56

csharp
SimpleButton buttonOk = new SimpleButton();
buttonOk.Text = "OK";
buttonOk.DialogResult = DialogResult.OK;

winforms-mvvm-best-practices/VB/DelegateCommands/SimpleCommandUserControl.vb#L15

vb
Dim commandButton As New SimpleButton()
commandButton.Text = "Execute Command"
commandButton.Dock = DockStyle.Top

winforms-map-convert-a-cartesian-data-shapefile-to-geo-coordinates/VB/MapSample/Form1.vb#L48

vb
btnSave.Enabled = True
btnPrj.Text = "2. Projection Loaded automatically"
btnPrj.Enabled = False

XAF-search-objects-using-complex-criterion/VB/Dennis.Search.Win/SearchObjectPropertyEditor.vb#L36

vb
btnSearchCore.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left
btnSearchCore.Text = Properties.Resources.SearchButtonText
AddHandler btnSearchCore.Click, AddressOf btnSearchCore_Click

spreadsheet-document-api-use-worksheet-data-bindings-to-process-data/VB/PerformanceCounterCorrelationExample/Form1.vb#L54

vb
If Not CreateCounters() Then Return
btnStart.Text = "Stop"
dataProvider = New PerformanceDataProvider(firstCounter, secondCounter)

winforms-dashboard-custom-properties/VB/WinForms-Dashboard-Custom-Properties/Modules/DashboardDescriptionModule.vb#L56

vb
Dim buttonOk As New SimpleButton()
buttonOk.Text = "OK"
buttonOk.DialogResult = DialogResult.OK

See Also

ImageOptions

SimpleButton Class

SimpleButton Members

DevExpress.XtraEditors Namespace