[]
Gets a value representing the currently selected tab in the designer interface.
[Browsable(false)]
public DesignerTab ActiveTab { get; }
Type | Description |
---|---|
DesignerTab | The DesignerTab representing the active tab in the designer. This property provides access to the tab currently being interacted with by the user, allowing for context-specific operations based on the selected tab. |
This property is particularly useful for determining the context within which the designer is operating, such as whether the user is focusing on design, preview, or Script. Accessing this property can help in tailoring the UI and functionality to better suit the needs of the current designer state.
Utilize the ActiveTabChanged event to respond to switches between the Script, Design, and Preview tabs. The ActiveTab property allows you to determine the currently active tab.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
designer = new Designer() { Dock = DockStyle.Fill };
designer.ActiveTabChanged += (sender, args) => {
//Get the currently editing report name.
var reportName = designer.Report switch
{
PageReport pageReport => pageReport.Report.Name,
SectionReport sectionReport => sectionReport.Name,
_ => "Report"
};
//Set the form title to reflect the current designer state
this.Text = designer.ActiveTab switch
{
DesignerTab.Script => $"{reportName} - Script",
DesignerTab.Preview => $"{reportName} - Preview",
_ => $"{reportName} - Edit"
};
};
Controls.Add(designer);
}
}