How do I get the Custom Property text from a Visio Shape in C#?

R

Russell_W

I am trying to retrieve the custom property text of a visio shape in
C#, I have used the following:

Shape myShape = ...;
IVSection vSection =
myShape.get_Section((short)VisSectionIndices.visSectionProp);

Now, how can I get the text of the Custom Property myProp on the shape
myShape?

Thanks in advance!

Russell
 
R

Russell_W

Markus,

I have seen your sample code, but once I get the property seciton as
an IVSection vSection from your code sample:

IVSection vSection =
myShape.get_Section((short)VisSectionIndices.visSectionProp);

Now how do I retreive the actual property label and value strings from
IVSection? The value of vSection[0].Name is "Row_1".

Russell
 
M

Markus Breugst

Russel,

you don't need the section object for getting/setting a cell value. You do
that directly on the shape, as shown in the news contribution I mentioned
previously. Here are the two rows again:

// set custom property label (_index = row number)
vShape.get_CellsSRC( (short) VisSectionIndices.visSectionProp, (short)
((short) VisRowIndices.visRowProp + _index), (short)
VisCellIndices.visCustPropsLabel ).Formula = newLabel;

// set custom property value (_index = row number)
vShape.get_CellsSRC( (short) VisSectionIndices.visSectionProp, (short)
((short) VisRowIndices.visRowProp + _index), (short)
VisCellIndices.visCustPropsValue ).Formula = newValue;

If you just want to get (not set) the cell values, just modify the lines
above as follows:

// get custom property label (_index = row number)
string _label = vShape.get_CellsSRC( (short)
VisSectionIndices.visSectionProp, (short)
((short) VisRowIndices.visRowProp + _index), (short)
VisCellIndices.visCustPropsLabel ).Formula;

// get custom property value (_index = row number)
string _value = vShape.get_CellsSRC( (short)
VisSectionIndices.visSectionProp, (short)
((short) VisRowIndices.visRowProp + _index), (short)
VisCellIndices.visCustPropsValue ).Formula;

Best regards,
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top