Back to Devexpress

How to: Respond to Clicking Close Button in XtraTabControl

windowsforms-9533-controls-and-libraries-editors-and-simple-controls-examples-how-to-respond-to-clicking-close-button-in-xtratabcontrol.md

latest1.1 KB
Original Source

How to: Respond to Clicking Close Button in XtraTabControl

  • Oct 25, 2019

The following example shows how to hide tab pages in the XtraTabControl when their Close buttons are clicked. To respond to clicking Close buttons, the XtraTabControl.CloseButtonClick event is handled.

csharp
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;

private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e) {
    ClosePageButtonEventArgs arg = e as ClosePageButtonEventArgs;
    (arg.Page as XtraTabPage).PageVisible = false;
}
vb
Imports DevExpress.XtraTab
Imports DevExpress.XtraTab.ViewInfo

Private Sub XtraTabControl1_CloseButtonClick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles XtraTabControl1.CloseButtonClick
    Dim arg As ClosePageButtonEventArgs = TryCast(e, ClosePageButtonEventArgs)
    TryCast(arg.Page, XtraTabPage).PageVisible = False
End Sub