Visual Studio Development Bookmark and Share   
 index > Visual Studio Extensibility > Create New Tab in Visual Studio
 

Create New Tab in Visual Studio

I have created a new tool window that lists in treeview format a bunch of entries in my database that have parent child relationships. Is there anyway that I can have a "tab" show up with very basic information about the object being double clicked from the tool window? And by tab I mean the kind of tab that would come up when you double click "My Projects" just a listing of what the object is, description etc.

I was looking for something similiar to the CreateToolWindow2 function but the only thing I have found so far are the CreateDocumentWindow and OpenStandardEditor methods but I am not sure how to go about using these. Are these the right methods to use to create the window I need? If so are there any examples that demostrate how to use these functions in an addin?

Thanks for your time.

New User1  Monday, March 05, 2007 8:23 PM

It sounds as if you've built your own toolwindow and want it to function similar to the Solution and Server Explorer toolwindiows. In that you'd like to launch an editor (or designer) when you dlbclick on an item in your tree control.

With the Solution and Server Explorer toolwindows, the dblclick action is processed by the underlying UIHierarchy interface that is fed to the VsUIHierarchyWindow. Typically, the dlbclick will launch an editor (or designer) by way of calling one of the methods off the IVsUIShellOpenDocument interface. OpenDocumentViaProject, or OpenSpecificEditor, etc. These methods requirean IVsUIHierarchy pointer, and an itemID, as the IDE will attempt to register these documents in the Running Document Table, and use the IVsUIHierarchy and itemID to tie the opened document to a specific project/hierarchy.

You could implement a custom IVsHierarchy/IVsUIHierarchy interface on your tree based toolwindow, so that you could leverage that IVsUIShellOpenDocument interface, or if the items in your toolwindow represent actual files, you could potentially use the DTE.ItemOperations.Open to open a specific file in the editor.

But in all likelihood, you'll probably want to implement a custom heirarchy for your treecontrol based toolwindow. I have a sample uploaded to the gotdotnet codegallery called HierAnarchy that implements a very minimal IVsUIHierarchy interface, but it's actually wired into a VsUIHierarchyWindow based toolwindow. You might want to give it a look over, as it could provide you with some ideas.

Sincerely,

Ed Dore  Monday, March 05, 2007 10:39 PM

I think that you are talking about the VS Properties window.

If thats correct you need to track the selection and notify VS to show the properties of the current selection on the VS Properties window.

To do that you need to:

On your tool window class you need to define a SelectionContainerglobal variable:

private Microsoft.VisualStudio.Shell.SelectionContainer selectionContainer;

Override the OnToolWindowCreated method

public override void OnToolWindowCreated()

{

selectionContainer = new Microsoft.VisualStudio.Shell.SelectionContainer();

}

Create a method to handle the selection

public void OnSelectionChange(ICollection selectedObjects)

{

ITrackSelection trackSelection = this.GetService(typeof(ITrackSelection)) as ITrackSelection;

if(trackSelection != null)

{

selectionContainer.SelectedObjects = selectedObjects;

selectionContainer.SelectableObjects = selectedObjects;

trackSelection.OnSelectChange((ISelectionContainer)selectionContainer);

}

}

On your control class on a specific event you need to call the OnSelectionChange method and pass the object/s you want to be displayed on the VS properties window.

Pablo

Pablo Galiano  Monday, March 05, 2007 8:53 PM

Thank you for your reply. I don't think this is quite what I had in mind.  Basically when you open and .vb file it opens in the up in the "main" area for visual studio in a tab, and every subsequest opening of documents creates a new "tab". I want to create a new "tab" every time a user double clicks on something in the tree that I have created, with information about the item that was double clicked.

 

 

EDIT:  I good example of the tab I am looking for is exactly like the Start Page, I just want to create a tab in that area.

New User1  Monday, March 05, 2007 10:02 PM

It sounds as if you've built your own toolwindow and want it to function similar to the Solution and Server Explorer toolwindiows. In that you'd like to launch an editor (or designer) when you dlbclick on an item in your tree control.

With the Solution and Server Explorer toolwindows, the dblclick action is processed by the underlying UIHierarchy interface that is fed to the VsUIHierarchyWindow. Typically, the dlbclick will launch an editor (or designer) by way of calling one of the methods off the IVsUIShellOpenDocument interface. OpenDocumentViaProject, or OpenSpecificEditor, etc. These methods requirean IVsUIHierarchy pointer, and an itemID, as the IDE will attempt to register these documents in the Running Document Table, and use the IVsUIHierarchy and itemID to tie the opened document to a specific project/hierarchy.

You could implement a custom IVsHierarchy/IVsUIHierarchy interface on your tree based toolwindow, so that you could leverage that IVsUIShellOpenDocument interface, or if the items in your toolwindow represent actual files, you could potentially use the DTE.ItemOperations.Open to open a specific file in the editor.

But in all likelihood, you'll probably want to implement a custom heirarchy for your treecontrol based toolwindow. I have a sample uploaded to the gotdotnet codegallery called HierAnarchy that implements a very minimal IVsUIHierarchy interface, but it's actually wired into a VsUIHierarchyWindow based toolwindow. You might want to give it a look over, as it could provide you with some ideas.

Sincerely,

Ed Dore  Monday, March 05, 2007 10:39 PM
But in all likelihood, you'll probably want to implement a custom heirarchy for your treecontrol based toolwindow. I have a sample uploaded to the gotdotnet codegallery called HierAnarchy that implements a very minimal IVsUIHierarchy interface, but it's actually wired into a VsUIHierarchyWindow based toolwindow. You might want to give it a look over, as it could provide you with some ideas.

Sincerely,


I'm sorry but what's the new link to "HierAnarchy" sample?
c# new learner
Fei.  Monday, October 12, 2009 5:54 AM

You can use google to search for other answers

Custom Search

More Threads

• How to programatically add a new resx file
• DebugPortSupplier/DebugPort
• Nesting files in c# projects
• Showing My Wizard in Web Project Add New Item Dialog
• How to support Code Coverage
• Interacting with Server Explorer
• Designer code for compact framework component not run at design time
• DSL Setup projects and SDM command prompt - an experience
• How to prevent exception@OAProperties.cs
• Solution.Globals not persisting