How to: Create a Top-Level Tab with a Windows Forms Custom Control

 

Updated: October 9, 2012

Applies To: Windows Server 2012 Essentials, Windows Home Server 2011, Windows Storage Server 2008 R2 Essentials, Windows Small Business Server 2011 Essentials

The Dashboard typically includes subtabs that contain a list pane, details pane, and task pane. You can choose to replace these panes with a Windows Forms custom control.

You must create a class that inherits ControlRendererPage class to add a Windows Forms custom control to your subtab.

To create a subtab with a custom control

  1. Ensure that you have finished the procedure listed in Create a Top-Level Tab, and ensure that you used the HSBSTopLevelTabWinforms template to create the tab.

  2. In the SubTab project, open the SubTabPage.cs file.

  3. You must provide identifying information for the page. Change the subtab name and description in the constructor of the class as well as the GUID passed to the base class’s constructor:

    
    public class SubTabPage : ControlRendererPage  
    {  
       public SubTabPage()  
          : base(new Guid([Insert new GUID here.]),   
          "SubTab Sample",   
          "SubTab Sample Description")  
       {  
       }  
    }  
    
    

    SubTab Sample is the name of your tab. SubTab Sample Description is the tool tip description for your tab that is displayed when the mouse hovers over the tab name.

    System_CAPS_ICON_note.jpg Note

    You must supply your own unique GUID. For more information about creating a GUID, see Create Guid (guidgen.exe) (http://go.microsoft.com/fwlink/?LinkId=116098).

  4. The CreateContent method uses the Create method of the ControlRendererPageContent class to initialize a ControlRendererPageContent object. The ControlRendererPageContent object is used by the Dashboard to display your custom control. In the following code sample, MyControl represents the custom Control that is displayed on the subtab:

    
    protected override ControlRendererPageContent CreateContent()  
    {  
       return ControlRendererPageContent.Create(new MyControl());  
    }  
    
    
  5. (Optional) You can provide help information for the page. The following code example shows how to override the CreateHelpTopicInfo method:

    
    protected override HelpTopicInfo CreateHelpTopicInfo()  
    {  
       // Replace with a custom URL or CHM/HTML file path.  
       return new HelpTopicInfo(new Uri("http://servername/help"));  
    }  
    
    

    You can also refer to help information in a compiled help file.

    
    protected override HelpTopicInfo CreateHelpTopicInfo()  
    {  
       HelpTopicInfo helpTopic = null;  
       helpTopic = new HelpTopicInfo(@"<path to help .chm file>",  
          @"/html/076d08c2.html");  
       return helpTopic;  
    }  
    
    
  6. In the SubTab project, open the MyCustomControl\MyControl.cs file. Add controls to define the user interface for the add-in.

  7. Save and build the solution.

Community Additions

ADD
Show: