KEVOS® Knowledge Library · SolidWorks API Add-in Development
Property Manager Pages and the Control Model
The handler class, the page creation call, the control catalogue and the identifier-driven callback model behind the panel most add-ins use as their primary interface.
- Doc № KL-ENG-COMP-005
- Engineering › Computers
- Part 05 of 10
- 8 min read
- Updated 2026-08-04
01Executive summary
A Property Manager Page is a panel hosted inside SolidWorks in the same position as the feature tree. It is the interface device most add-ins reach for, because it looks and behaves like the native modelling commands rather than like a bolted-on dialog.
The pattern is consistent: a handler class implements the page handler interface, creates the page in its constructor, adds controls in a dedicated method, and receives every user interaction through callback methods that identify the control by an integer you assigned. The discipline that makes this pleasant rather than painful is the identifier convention — one constant per control, one field per control handle, and no exceptions.
02The handler class
Pages are driven by a class that implements the page handler interface. Implementing it generates a long list of members — these are the callbacks SolidWorks invokes as the user interacts with the page. Most will remain empty; the ones you fill are the page's behaviour.
- Implement the handler interface
Generate every member of the interface. Clear the auto-generated bodies, return a benign value from any member that returns one, and leave the rest empty until needed.
- Create the page in the constructor
The constructor takes the application object and creates the page, so that constructing an instance and having a page are the same event.
- Add controls in a dedicated method
Called immediately after successful creation. Keeping it separate makes the layout readable and lets you rebuild controls without recreating the page.
- Expose an explicit show method
Creation and display are separate concerns. A page can exist without being visible, which is what multi-page add-ins rely on.
- Release in the after-close callback
Null the page handle and every control handle when the page closes, not when the add-in unloads.
03Creating the page
object CreatePropertyManagerPage(
string Title,
int Options,
object Handler,
ref int Errors
)
- Title
- Heading shown at the top of the panel.
- Options
- Bit mask from the page options enumerator. Common members select the green confirmation button, a close button, and whether the page is locked so that it stays put during other operations.
- Handler
- The instance implementing the page handler interface that will receive the callbacks — normally the class making the call.
- Errors
- Passed by reference and populated with a value from the page status enumerator. It must be checked: creation can fail while still returning an object.
public bool Ok { get; private set; }
private IPropertyManagerPage2 _page;
private ISldWorks _sw;
private int _errors;
public InfoPage(ISldWorks app)
{
_sw = app;
try
{
_page = (IPropertyManagerPage2)_sw.CreatePropertyManagerPage(
"Model information",
(int)(swPropertyManagerPageOptions_e
.swPropertyManagerOptions_OkayButton |
swPropertyManagerPageOptions_e
.swPropertyManagerOptions_LockedPage),
this,
ref _errors);
// A returned object does not mean success.
if (_errors != (int)swPropertyManagerPageStatus_e
.swPropertyManagerPage_Okay)
{
Report("Page could not be created: " +
((swPropertyManagerPageStatus_e)_errors));
Ok = false;
return;
}
AddControls();
Ok = true;
}
catch (Exception ex)
{
Report("Page could not be created: " + ex.Message);
Ok = false;
}
}
The status value reports a page that the API declined to build. The exception path catches everything else. Handling only one of them leaves a class that reports success and then fails at the moment it is shown — inside the host process.
04The control catalogue
Controls are added to the page after it exists. Every control needs a caption, an alignment, an options mask and a tooltip; because most controls share the same alignment and options, those are normally computed once and reused.
object AddControl(
short ID,
short ControlType,
string Caption,
short LeftAlign,
int Options,
string Tip
)
- ID
- Your identifier for the control. It is the value handed back to you in every callback, so it is how you know which control the user touched.
- ControlType
- A member of the control type enumerator.
- Caption
- Label text for the control.
- LeftAlign
- A member of the left-alignment enumerator, controlling indentation against the page edge or the enclosing group.
- Options
- Bit mask combining at minimum the enabled and visible flags.
- Tip
- Hover text for the control.
- Return value
- A handle to the created control, typed to the control class. Store it — you will need it to read and write values later.
| Control | Typical use | Primary callback |
|---|---|---|
| Label | Static text and captions | None |
| Textbox | Free text entry and read-back of values | Text changed |
| Numberbox | Numeric entry with units and range | Value changed |
| Checkbox | Independent on/off setting | Check changed |
| Option | Mutually exclusive choice within a group | Option checked |
| Combobox | Selection from a generated list | Selection changed |
| Listbox | Selection from a longer or multi-select list | Selection changed |
| Button | Discrete action | Button pressed |
| Bitmap button | Action represented by an icon | Button pressed |
| Checkable bitmap button | Toggle represented by an icon | Check changed |
| Selectionbox | Capturing geometry selected in the graphics area | Selection changed |
| Slider | Bounded continuous adjustment | Position changed |
| Bitmap | Static image | None |
| ActiveX control | Hosting an external control | Control created |
private const short IdFileName = 1;
private const short IdRefresh = 2;
private const short IdSheetList = 3;
private IPropertyManagerPageLabel _lblFileName;
private IPropertyManagerPageButton _btnRefresh;
private IPropertyManagerPageCombobox _cboSheets;
private void AddControls()
{
_page.SetMessage3(
"Information about the active document.",
(int)swPropertyManagerPageMessageVisibility
.swImportantMessageBox,
(int)swPropertyManagerPageMessageExpanded
.swMessageBoxMaintainExpandState,
"Model information");
int opts = (int)(swAddControlOptions_e.swControlOptions_Enabled |
swAddControlOptions_e.swControlOptions_Visible);
short align = (short)swPropertyManagerPageControlLeftAlign_e
.swControlAlign_LeftEdge;
_lblFileName = (IPropertyManagerPageLabel)_page.AddControl(
IdFileName,
(short)swPropertyManagerPageControlType_e.swControlType_Label,
"Document", align, opts, "Active document name");
_btnRefresh = (IPropertyManagerPageButton)_page.AddControl(
IdRefresh,
(short)swPropertyManagerPageControlType_e.swControlType_Button,
"Refresh", align, opts, "Re-read the active document");
}
Every page carries a hidden group and label at the top. Setting its message and visibility reveals it, which gives you a conventional place to explain what the page does or to report state without adding a control of your own.
05The identifier-driven callback model
Interaction does not arrive as a delegate attached to a control. It arrives as a call to a handler member, carrying the identifier you assigned. One method therefore serves every button on the page, and dispatch is your responsibility.
public void OnButtonPress(int Id)
{
switch (Id)
{
case IdRefresh:
RefreshFromActiveDocument();
break;
}
}
public void OnComboboxSelectionChanged(int Id, int Item)
{
switch (Id)
{
case IdSheetList:
ActivateSheet(Item);
break;
}
}
public void AfterClose()
{
// Release page and control handles here, not at unload.
_cboSheets = null;
_btnRefresh = null;
_lblFileName = null;
_page = null;
}
Number identifiers from one, declare them as constants next to the field holding the control handle, and never reuse a value. When a page grows past a dozen controls this convention is the only thing standing between you and a switch statement full of magic numbers.
06Showing, hiding and multi-page behaviour
Creation and display are deliberately separate. An add-in that presents a different layout for parts, assemblies and drawings creates the controls for all three, then shows and hides groups as the active document changes — which is far cheaper than tearing down and rebuilding the page on every switch.
- Create once
Build the page and every control group at construction, including the groups that are not initially relevant.
- Toggle visibility
On a document change, hide the groups that do not apply and show the one that does, then repopulate its values.
- Show with the right mode
The display call takes a mode argument. The stacked mode is what keeps a page open across the events that would otherwise dismiss it — essential for a page intended to persist while the user works.
- Release on close
Handle the after-close callback and null every handle. The page may be closed by the user at any time, independently of the add-in's lifetime.
Page display modes interact with the host's own event handling, and behaviour has historically varied between installations. A page that stays open reliably on the development machine is not evidence that it will do so everywhere. Test persistence across a spread of workstations before relying on it.
07Quick reference
- Handler
- One class implementing the page handler interface; every member generated, most left empty.
- Creation
- Title, options mask, handler, and an error value passed by reference — check it.
- Controls
- Added after creation; each returns a typed handle you must store.
- Identity
- One constant identifier per control, matched to the field holding its handle.
- Interaction
- Callbacks carry the identifier; dispatch is yours to write.
- Message area
- Built into every page; reveal it rather than adding a label of your own.
- Teardown
- Null the page and all control handles in the after-close callback.
08Where this leads
Continue in this pathway
- Part 01Add-in architecture and the integration model
- Part 02Development environment and project configuration
- Part 03COM registration and add-in discovery
- Part 04Command Manager, menus and toolbars
- Part 05Property Manager Pages and the control model
- Part 06Event and notification architecture
- Part 07Add-in, stand-alone or hybrid
- Part 08Planning, structure and debugging discipline
- Part 09Deployment methods and installer engineering
- Part 10Licensing, distribution and commercialisation
