Building Property Pages

By default, Vault Explorer provides the View Properties Grid which provides a list of all property values for the selected object.  This is a nice default view, but us developers commonly want to have customized property views (aka. property pages).  So here is a quick primer on creating property pages in Vault Explorer.

Note:  This article is basically a condensed version of Dan Leighton’s excellent AU 2011 class, Manage Dozens of Autodesk Vault Workgroup Properties with Custom Forms and Reports.  If you have the time, feel free to skip the rest of this post and view the video on the AU site.  Also, his handout is full of sample code!


The first step is to set up your project for writing a Vault Explorer extension.  You can read up on this in the SDK documentation.  Or you can just copy the HelloWorld example and build off that. 

Property pages in Vault Explorer most commonly take the form of custom tabs or custom dialogs.  I’ll be showing an example of a custom tab, which means we start by defining our own User Control (right click on your project and select Add –> User Control).  Now we have a blank control.  Next you drag and drop controls from the Toolbox into your custom control.  Usually each property will have two controls, one to display the property name and one to display the property value. A Label control is usually used for the property name.  The value is usually represented by a TextBox, but there are tons of controls to choose from.  Other useful controls are ComboBoxes, CheckBoxes, DateTimePickers, RadioButtons, and so on.  For this example, I’ll keep it simple and just stick to TextBoxes.

Now that we have our controls in place, we need a way to map the specific property values to the correct controls.  Sure we could just hard code the mapping for each TextBox, but that doesn’t leave us with any reusable code.  It also doesn’t make things easy for us in the future if we have to make changes to our property page.  A better way is to add meta-data to our controls.  At runtime we route the property data to the correct control based on the meta-data.

There are a couple of ways to set the meta-data on a control.  In this example, I’ll use the “Tag” property.  I want to set my TextBox Tag values to something that will let me locate the Vault property.  You can use the display name of the Vault property if you are sure that it won’t change.  Otherwise, I suggest using the system name.

Now we have our control, and our TextBoxes are smart enough to know what Vault property they are supposed to display.  The next step is to write code that looks up the Vault properties on a File and routes those values to the correct TextBox…
Or you could just copy my code from the examples below.

Click here for C# code
Click here for VB.NET code


Here is the final output.

If we ever need to display more properties on the page, it’s as easy as dropping in the new TextBox and setting the Tag value.

This is just a simple example to get you started.  More complex cases involve different data types, different control types and allowing the user to edit values through your property page. 


Comments

5 responses to “Building Property Pages”

  1. Hi Doug,
    Thanks again for this great and sample. Dan Leighton’s class was indeed fun & great to attend…!
    I have two questions regarding the property pages:
    1) Would it be possible to include some general code in an extension (pretty much similar to what included in this blog item), but instead of compiling an userform in the extension make a reference in the extension to a webpage?
    The workflow i am thinking of is to add a webpage to the IIS which is being used by Vault. Then add a detailpane tab with a WebBrowser control on it and load the webpage.
    The extension should load all the right properties into the controls which are placed on this webpage. This workflow would make it very easy to make changes to the properties shown and the positions of the controls without having to recompile the extension.
    Would it be possible? Do you have any tips or concerns about this workflow? (I personally never did something with aspx pages)
    2) In the current Vault API it is possible to add custom DetailPane tabs, but it’s not possible to change the order of the tabs.. Could that be made possible in a future release? Or is that impossible to introcude? (I would like the Property Page for example to be before the History tab).

  2. 1) I don’t have much experience programming web pages either, but in theory you can apply the same techniques as with a winform dialog.
    Based on our own web client, I can say that managing the Vault security is one of the difficult aspects of this approach. For example…
    How do you maintain the Vault credentials? How do you know when to log out of Vault?
    2) It’s not possible to control the tab order, and it’s not on our roadmap. But I’ll keep the feature in mind. Thanks.

  3. Mike Collins Avatar
    Mike Collins

    Hi Doug,
    What font are you using on your form?

  4. I just stick to the Visual Studio default. Microsoft Sans Serif is the font, I think.
    Why do you ask?

  5. Mike Collins Avatar
    Mike Collins

    I just thought it looked sharp, and it didn’t seem like my default font looked that good.

Leave a Reply to Mike CollinsCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading