skip to main |
skip to sidebar
Display a SmartPart
in a SmartPartPlaceholder
- Open the form or user control from the Solution Explorer in design view.
- If the toolbox does not contain the SmartPartPlaceholder control, right-click the toolbox and click Choose Items. Click Browse, locate the Microsoft.Practices,CompositeUI.WinForms library, click Open, and then click OK.
- Drag a SmartPartPlaceholder control onto the form or user control.
- Use the Properties window to set the SmartPartName property of the SmartPartPlaceholder to the name you will use to identify the SmartPart that will be shown inside the placeholder at run time.
- Create the SmartPart with that name from a WorkItem as shown in the following code.
myWorkItem.Items.AddNew("Calendar");
CustomerView view = myWorkItem.Items.AddNew("Customer");
myWorkItem.Workspaces["Main"].Show(view);
in a Workspace- Open the form or user control from the Solution Explorer in design view
- If the toolbox does not contain the TabWorkspace, ZoneWorkspace, and DeckWorkspace controls, right-click the toolbox and click Choose Items. Click Browse, locate the Microsoft.Practices,CompositeUI.WinForms library, click Open, and then click OK
- Drag the required workspace control (TabWorkspace, ZoneWorkspace, or DeckWorkspace) onto the form. Note that the MdiWorkspace and WindowWorkspace controls do not appear in the toolbox, and do not support drag and drop. Instead, they must be instantiated in code.
- Call the Show method of the Workspace, in this case a workspace named deckWorkspace1, passing to it the SmartPart to display as shown in the following code.
Form1 mainForm = new Form1();
CustomerSmartPart sp = myWorkItem.Items.AddNew();
mainForm.deckWorkspace1.Show(sp);
No comments:
Post a Comment