How to create a tabbed view
A tabbed view is a Site Manager view that has an embedded tab control object. It is usually a simple view that only has the tab control embedded but there are exceptions and there is nothing stopping you from creating more complex tabbed views.
Adding tabs to a tabbed view
The next chapter explains how to add a tab to a tabbed view in the Site Manager. We will assume here that you already have a tab that you want to add to the view. If you need to create a new tab see chapter How to create a tab .
When adding a tab to a tabbed view it matters if you are adding to your own view or if you are adding tab to a tabbed view in another plugin.
Let’s take a look at each scenario:
Adding to your view
When adding a tab to your own tabbed view you need to define the tabs within the control and then directly add them to the tab control object.
Here we have code that adds an instance the ‘Tab1’ tab to the tab control ‘tabControl’
TabControl.Tab tab1 = new TabControl.Tab
(
"Text for tab 1",
ViewPages.Tab1ViewPage.CreateInstance
)
tabControl.AddTab(tab1)
This code can, for example, be located in the constructor of the tabbed view. Notice that we are using the CreateInstance method of the tab to get an instance of the tab.
Adding to an existing view
When adding a tab to a view that already exists in the Site Manager you need to add code to your IPlugin implementing class (usually called PluginEntry).
The code you need to add is in the Init function of the PluginEntry.
internal static IConnectionManager DataModel = null;
internal static IApplicationCallbacks Framework = null;
...
public void Init(IConnectionManager dataModel,
IApplicationCallbacks frameworkCallbacks
{
DataModel = dataModel;
Framework = frameworkCallbacks
...
Controls.TabControl.TabPanelConstructionHandler +=
PluginOperations.ConstructTabs;
}
Here we are telling the Site Manager that the function PluginOperations.ConstructTabs exists and that in it we want to add tabs to other views.
Let’s take a look at that code:
internal static void ConstructTabs(object sender,
TabPanelConstructionArguments args)
{
if (args.ContextName == "LSOne.ViewPlugins.Administration.Views.AdministrationView")
{
args.Add(new TabControl.Tab(Properties.Resources.Hello, HelloWorldViewPage.CreateInstance), 30);
}
}
In the args.ContextName we have the name and namespace of the view that we are going to add the tab into. Here you see that we are adding to the AdministrationView in the Administration plugin.
Within the if statement we add the tab. In the code above we see that we are adding the HelloWorld tab. The first parameter of the tab is the header text for the tab and the second parameter is a method that returns an instance of the tab (this method is usually located within the tab itself). The last parameter is the priority number of the tab. This number determines where the tab is located among the other tabs.
Sending data to tabs
Once we have added some tabs we need to send them some data. This is usually done in the LoadData function of the tabbed view.
protected override void LoadData(bool isRevert)
{
...
tabControl.SetData(isRevert, dataId, dataObject);
...
}
The only code shown is the code where we are sending data to the tabs. The tabs will receive this call in their LoadData functions. There they can respond by either using the ID of the data object that the tabbed view is handling (it might for example want to fetch some extra data based on the ID of the object) or it might want to use information directly from the original data object that the tabbed view is sending.
Tabs can also be added to dialogs: How to create a tabbed dialog