Dynamically generated Workspaces

May 2, 2007 at 8:11 AM
Edited May 2, 2007 at 8:12 AM
Anyone know how to reference a dynamically generated WorkSpace? Also are their any issues to watch out for with dynamically generated worksapces?

The commented out line below fails.

public void OnShowClientSearch(object sender, EventArgs e)
{
TabWorkspace tabWorkspace = (TabWorkspace)WorkItem.WorkspacesWorkspaceNames.MainTabWorkspace;

//Create a new Deck workspace on Tab Panel
DeckWorkspace deckWorkspace = new DeckWorkspace();
deckWorkspace.Name = "ArbitaryWSName";
deckWorkspace.Dock = System.Windows.Forms.DockStyle.Fill;

//Add DeckWorkspace to a new tab
TabPage tabPage = new TabPage("Client Search");
tabPage.Controls.Add(deckWorkspace);
tabWorkspace.TabPages.Add(tabPage);

//Add the view to the new DeckWorkspace
ClientSearchView clientSearchView = WorkItem.SmartParts.AddNew<ClientSearchView>();
deckWorkspace.Show(clientSearchView);

//WorkItem.Workspaces"ArbitaryWSName".Show(view); //******THIS FAILS********
}
May 3, 2007 at 2:53 AM
I think the problem might be that you haven't added the WorkSpace to the WorkItem and therefore some required dependencies weren't built by CAB.

Try changing your code from:
DeckWorkspace deckWorkspace = new DeckWorkspace();
deckWorkspace.Name = "ArbitaryWSName";
deckWorkspace.Dock = System.Windows.Forms.DockStyle.Fill;

To:
DeckWorkspace deckWorkspace = WorkItem.WorkSpaces.AddNew<DeckWorkspace>("ArbitaryWSName");
//deckWorkspace.Name = "ArbitaryWSName";
deckWorkspace.Dock = System.Windows.Forms.DockStyle.Fill;

Just an idea, I haven't tried and I could be crazy ;0)
May 3, 2007 at 4:48 AM
Your not crazy! Worked like a dream. Thanks