Back to Devexpress

TabFormControlBase.AddPageButton Property

windowsforms-devexpress-dot-xtrabars-dot-tabformcontrolbase-5e317196.md

latest3.7 KB
Original Source

TabFormControlBase.AddPageButton Property

Provides access to the Add button, and allows you to bind a command executed with a button click.

Namespace : DevExpress.XtraBars

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[Browsable(false)]
public TabFormAddPageButton AddPageButton { get; }
vb
<Browsable(False)>
Public ReadOnly Property AddPageButton As TabFormAddPageButton

Property Value

TypeDescription
DevExpress.XtraBars.TabFormAddPageButton

A DevExpress.XtraBars.TabFormAddPageButton object that represents the Add button.

|

Remarks

If the TabFormControlBase.ShowAddPageButton setting is enabled, the TabForm displays the built-in Add button.

By default, with a click on that button, an end-user creates a new tab page. This button supports the WinForms MVVM Framework, and it is possible to bind it with a DelegateCommand. The AddPageButton property provides access to the button, and allows you to bind a DelegateCommand using the BindCommand method. The code snippet below shows how to show a message box and create a new tab page with a click on the button, using the DelegateCommand object.

csharp
using DevExpress.Mvvm;

DelegateCommand command = new DelegateCommand(() => {
    MessageBox.Show("Hello! I'm running!");
    tabFormControl1.AddNewPage();
});

tabFormControl1.AddPageButton.BindCommand(command);
vb
Imports DevExpress.Mvvm

Dim command As New DelegateCommand(Function()
                                       MessageBox.Show("Hello! I'm running!")
                                       TabFormControl1.AddNewPage()
                                   End Function)

TabFormControl1.AddPageButton.BindCommand(command)

Note that if a custom command is bound to the Add button, the default action (creating a new page) is not performed. To create a new page in the bound command, use the TabFormControlBase.AddNewPage method.

If a command is bound to the button, the button visibility depends on whether the command can be executed. If the command cannot be executed, the button is automatically hidden. To specify whether the command can be executed, use the DelegateCommand constructor with the corresponding parameters. For more details, see the Commands topic in the WinForms MVVM documentation.

See Also

MVVM Commands

TabFormControlBase Class

TabFormControlBase Members

DevExpress.XtraBars Namespace