locked
How to add tab in Visual Studio 2008 RRS feed

  • Question

  • Hello,

    I am new in Add-In project. I created a new Add-In project in VS 2008. Now how can i add new tab in following function:

    public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)

    {

    handled = false;

    if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)

    {

    if(commandName == "MyAddin1.Connect.MyAddin1")

    {

    handled = true;

    return;

    }

    }

    }

     

    Wednesday, March 24, 2010 4:17 PM

Answers

  • To manipulate Windows Forms controls first you need the IDesignerHost interface, then you get the control. For most properties you need to use a PropertyDescriptor rather than changing directly the property value. I am not sure about calling methods (Tabs.Add) rather than simply modifying properties. See if this article helps:

    HOWTO: Manipulating controls of Windows forms from Visual Studio .NET add-ins.
    http://www.mztools.com/resources_vsnet_addins.aspx


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Wednesday, March 31, 2010 9:30 AM
    Thursday, March 25, 2010 11:54 AM

All replies

  • right after the handled = true;

     

    you would put a call to your code for adding a tab...

     

    and what exactly do you mean "add a new tab"? are you adding a tab to the visual studio? Adding a file? adding a tab to a tabbed control?

    Wednesday, March 24, 2010 5:00 PM
  • Thanks for your reply,

    I want to add a tab to a tabbed control and in that new tab i want to add my own user control. Could anyone tell me how can i do this?

    any help is highly appreciated. 

     

    Thursday, March 25, 2010 1:25 AM
  • To manipulate Windows Forms controls first you need the IDesignerHost interface, then you get the control. For most properties you need to use a PropertyDescriptor rather than changing directly the property value. I am not sure about calling methods (Tabs.Add) rather than simply modifying properties. See if this article helps:

    HOWTO: Manipulating controls of Windows forms from Visual Studio .NET add-ins.
    http://www.mztools.com/resources_vsnet_addins.aspx


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Wednesday, March 31, 2010 9:30 AM
    Thursday, March 25, 2010 11:54 AM