HOW TO: Use SmartPartPlaceHolder

Topics: CAB & Smart Client Software Factory
Dec 22, 2005 at 8:37 AM
originally posted by: lfajardo

Can I add a workspace (deck) that is going to display multiple SmartParts and use SmartPartPlaceHolder to define where the SmartParts are going to be displayed?

I have this :

In my ShellForm, I have a DeckWorkspace: searchWorkspace, I place a SmartPartPlaceHolder in the workspace and assign the SmartPartName to searchView.

Then...

In MyModule I have a WorkItem doing this:


CustomerSearchView searchView = Items.AddNew<CustomerSearchView>("searchView");
searchWS.Show(searchView);

where searchWS is the workspace in the shell.

The SmartPart is displayed on the workspace but is not displayed on the SmartPartPlaceHolder.

What's the right way to do it?

Thanks
Dec 23, 2005 at 10:37 AM
originally posted by: aaarrrggh

I have the same question. Works in a workspace, not in the place holder alone.
Dec 28, 2005 at 7:42 AM
originally posted by: BradWilsonMSFT

Placeholders will look for smart parts in the WorkItem with the given name when they're created. Since the smart part doesn't exist when the form is created, the placeholder is empty.
Dec 28, 2005 at 7:58 AM
originally posted by: aaarrrggh

So if I have something like this:

MySmartPart part = SmartParts.AddNew<MySmartPart>("MySmartPart");
MySmartPartDialog dlg = Items.AddNew<MySmartPartDialog>("Dialog");

dlg.ShowDialog();

where my dialog contains a placeholder and the placeholder part name is "MySmartPart," it should work?

Thanks!
Dec 28, 2005 at 8:18 AM
originally posted by: BradWilsonMSFT

Yep! :)
Dec 28, 2005 at 11:11 AM
originally posted by: aaarrrggh

I've got a SmartPart that I'm instantiating in the WorkItem like this:

SmartControlView ctrl2 = this.SmartParts.AddNew<SmartControlView>("SmartControl2");

After I create the SmartPart, I create a new Form like this:

Form2 form = RootWorkItem.Items.AddNew<Form2>();

The form contains a SmartPartPlaceholder:

this.smartPartPlaceholder2.BackColor = System.Drawing.Color.Transparent;
this.smartPartPlaceholder2.Location = new System.Drawing.Point(12, 211);
this.smartPartPlaceholder2.Name = "smartPartPlaceholder2";
this.smartPartPlaceholder2.Size = new System.Drawing.Size(268, 197);
this.smartPartPlaceholder2.SmartPartName = "SmartControl2";
this.smartPartPlaceholder2.TabIndex = 3;
this.smartPartPlaceholder2.Text = "smartPartPlaceholder2";

When I do form.ShowDialog(), I don't see the smart part, and if I step through, it looks like it's not connected to the placeholder.

Thanks very much for the help!
Dec 28, 2005 at 3:30 PM
originally posted by: BradWilsonMSFT

I'm guessing here based on:

SmartControlView ctrl2 = this.SmartParts.AddNew<SmartControlView>("SmartControl2");
Form2 form = RootWorkItem.Items.AddNew<Form2>();

The smart part is in a child work item, but the form is in the root work item. That's why the form is not seeing the smart part.
Dec 29, 2005 at 10:31 AM
originally posted by: aaarrrggh

That did it! Thanks very much for the help. I just spent a few days converting our application to the December release of CAB (we have been using the summer release). It took some work, but I like the changes you've made for the December release.