Adding Properties to Shape programmatically

Hi,


i dont want to add properties of shape in visio like Data---->Shape Data

how we can define custom properties of shape in visio file programmatically,

Thanks
Raveendra


Hi Raveendra,

You can use the following code:

Prop prop = new Prop();
prop.Name = "EmployeeId";
prop.Value.Ufev.Unit = MeasureConst.STR;
prop.Value.Val = "NUM123456";
shape.Props.Add(prop);

Please feel free to contact us in case you have further comments or questions.

Best Regards,

Hi
Muhammad Ijaz,


Thanks for your support. what ever you given code is working fine for me.
here i am able to creating only properties releated to number
how can i create properties string type.


Thanks
Raveendra

Hi Raveendra,

Previous code actually defines a string property as you can notice the value of property is a string. Following code adds two properties; first one is number and second is string.

Prop prop = new Prop();
prop.Name = "EmployeeId";
prop.Type.Value = TypePropValue.Number;
prop.Value.Ufev.Unit = MeasureConst.NUM;
prop.Value.Val = "123456";
shape.Props.Add(prop);
prop = new Prop();
prop.Name = "EmployeeName";
prop.Value.Ufev.Unit = MeasureConst.STR;
prop.Value.Val = "String Prop";
shape.Props.Add(prop);

Best Regards,