Setting String Values to User-defined Cell Rows in Shapesheet

Hi there,

I am evaluating the use of Aspose in a Visio solution that currently makes use of .VSSX stencils and interop with C#.

I have come across an issue when using the Aspose API to work with the user-defined cells in the shapesheet. In interop I am able to do the following to turn a rectangle shape into a container:

indent preformatted text by 4 spaces

rectangle.AddRow((short)VisSectionIndices.visSectionUser, (short)VisRowIndices.visRowUser, (short)VisRowTags.visTagDefault);
rectangle.CellsU[“User.Row_2”].RowName = “msvStructureType”;
rectangle.CellsU[“User.msvStructureType”].FormulaForceU = “=“Container””; //sets row value to “Container”, makes shape a container

        rectangle.AddRow((short)VisSectionIndices.visSectionUser, (short)VisRowIndices.visRowUser, (short)VisRowTags.visTagDefault);
        rectangle.Cells["User.Row_3"].RowName = "msvSDContainerResize";
        rectangle.CellsU["User.msvSDContainerResize"].FormulaForceU = "=1";   //sets row value to 1, container resizes according to how many shapes are within it

        rectangle.AddRow((short)VisSectionIndices.visSectionUser, (short)VisRowIndices.visRowUser, (short)VisRowTags.visTagDefault);
        rectangle.Cells["User.Row_4"].RowName = "msvSDContainerMargin";
        rectangle.CellsU["User.msvSDContainerMargin"].FormulaForceU = "=20 mm*DropOnPageScale";    //sets the margin between shapes and container edges

I have used the User object in the Aspose.Diagram API to add three rows in the User-defined cells.

The value of the user-defined cell which I have set e.g.

indent preformatted text by 4 spaces

        User myUser3 = new User();
        myUser3.NameU = "msvSDContainerMargin";
        myUser3.Value.Val = "20mm*DropOnPageScale";

Only 20 appears in the shapesheet in the row’s value without the remainder “…mm*DropOnPageScale”. The third line in the above example only seems to work for integer values but not string values. I have looked online regarding this issue but to no avail.

I have attached a sample program highlighting my issue. This also includes the .vssx file I am using as well as the output file for reference. (105.3 KB)

Any guidance/ideas are appreciated. Thank you :slight_smile:


Would you please try to set the unit of the value like following code snippet:

 myUser3.Value.Ufev.Unit = Diagram.MeasureConst.STR;

Hi Asad,

That has worked great for setting the first user-defined cell row to “Container”. However, for the last row where I am setting the value to “20mm*DropOnPageScale”. I don’t want this to be a string value as this produces an undesired behaviour for the shape. The actual result is below:

image.png (24.6 KB)

What I want to appear in the row value is “20mm*DropOnPageScale” without the quotation marks in the shapesheet table. I suppose I could describe this as a formula which has a mix of integer and string types. Below is what I want to happen:

image.png (18.4 KB)

Is there a way I can achieve this?

Any ideas/guidance is appreciated :slight_smile:


I have tried this with:

myUser3.Value.Ufev.F = "20mm*DropOnPageScale";

However, in Visio I have to click on the value in the shapesheet cells and press enter (on my keyboard) to ‘force’ the value to be set in the shapesheet cell row.

Is there a way to force the value to be set without having to do this?

Thank you.

Any ideas/guidance is appreciated :slight_smile:


We need to further investigate the scenario which you have mentioned and for the purpose, we have logged a ticket as DIAGRAMNET-51855 in our issue tracking system. We will further check this in details and keep you posted with the status of ticket resolution. Please spare us some time.

Hi Asad,

I have seen the ticket DIAGRAMNET-51855 has the status ‘Won’t Fix’. Is there a reason why this may be the case?

I have managed to play around with the code. I somehow managed to have the formula forced into the Visio shapesheet for the rectangle container adding this:

myUser3.Value.Ufev.Unit = MeasureConst.MULTIDIM;

This line of code in context:

        User myUser3 = new User();
        myUser3.NameU = "msvSDContainerMargin";
        myUser3.Value.Ufev.Unit = MeasureConst.MULTIDIM;
        myUser3.Value.Ufev.F = "20mm*DropOnPageScale";

The thing is I want to know how I can add a stencil icon into the container. With interop in C# I am able to do the following in order to add a stencil icon into a container:

myContainer.ContainerProperties.AddMember(stencilToDrop, VisMemberAddOptions.visMemberAddExpandContainer);

I have tried gluing a stencil icon into the container, the container does not expand to fit the stencil icon. This is done via the code:

        myDiagram.AddMaster(directory + "AZURECLOUD_U.VSSX", "Application Insights");
        var applicationInsightsID = myPage.AddShape(3, 4, "Application Insights");
        Shape applicationInsightsShape = myPage.Shapes.GetShape(applicationInsightsID);
        myPage.GlueShapes(applicationInsightsID, Aspose.Diagram.Manipulation.ConnectionPointPlace.Center, rgContainer.ID);

However, when I go into Visio, the icon only sits in the container which hasn’t expanded. I have to drag the icon out of the container and drag it back into the container in order for the container to expand as intended.

Is there a way I can attach a stencil icon into the container where the container then expands and makes the icon a part of the container?

Is there also a way for me to have multiple stencil icons placed in the container whereby the container will automatically expand itself for multiple stencil icons?

I await your response and thank you for providing support :smile:

Thank you :slight_smile:


The status is so because it was not an issue in the API and could be resolved by a code reformation. Nevertheless, it is good to know that you were able to achieve your requirements. Furthermore, we have noticed your other requirements and logged them under the same ticket. We will investigate them and share our feedback with you soon.


Would you please try using following code snippet in order to achieve your requirements:

page.GlueShapesInContainer(shape1.ID, "PCI3Begin", "PCI3End", shape2.ID);  

Hi Asad,

I had a look at using this code snippet. However, I get a DiagramException where the connection cannot be found (‘cannot find connection’). This happens when I only use the code snippet. I found I needed to create instances of the connection class and define their values in the shapesheet before using the code snippet:

Connection myConnection1 = new Connection();
myConnection1.Name = "PCI3Begin";
myConnection1.X.Ufe.Unit = MeasureConst.MULTIDIM;
myConnection1.Y.Ufe.Unit = MeasureConst.MULTIDIM;
myConnection1.DirX.Ufe.Unit = MeasureConst.IN;
myConnection1.DirY.Ufe.Unit = MeasureConst.IN;
myConnection1.X.Ufe.F = "Width*0.5";
myConnection1.Y.Ufe.F = "Height*0.5";
myConnection1.DirX.Value = 0;
myConnection1.DirY.Value = 1;

Connection myConnection2 = new Connection();
myConnection2.Name = "PCI3End";
myConnection2.X.Ufe.Unit = MeasureConst.MULTIDIM;
myConnection2.Y.Ufe.Unit = MeasureConst.MULTIDIM;
myConnection2.DirX.Ufe.Unit = MeasureConst.IN;
myConnection2.DirY.Ufe.Unit = MeasureConst.IN;
myConnection2.X.Ufe.F = "Width*0.5";
myConnection2.Y.Ufe.F = "Height*0.5";
myConnection2.DirX.Value = 0;
myConnection2.DirY.Value = 1;

myPage.GlueShapesInContainer(applicationInsightsID, "PCI3Begin", "PCI3End", rgContainer.ID);

This results in: image.png (45.3 KB)

What I found is that I actually want to:

  • Add a stencil icon shape at position (x,y) on the page.
  • Add the icon to the container where the icon is related to the container (not connected to a specific position on the container as I want multiple icons in the container arranged in a row).
  • Have the container expand so that the icon at position (x,y) is inside the container.

I can do this via interop:

 Shape resourceToDrop = page.Drop(stencilIcon, x, y);
 container.ContainerProperties.AddMember(resourceToDrop, VisMemberAddOptions.visMemberAddExpandContainer);

Is there a way I can replicate this behaviour using Aspose.Diagram?

Any ideas are appreciated :slight_smile:


We are checking the code snippet in our environment and will share our feedback with you soon.


Meanwhile we are investigating the scenario, would you kindly share sample files which you are using at your side. This would help us testing the scenario accordingly.

Hi Asad,

I have attached a .zip containing the source code, required .vssx files and output files. (1.4 MB)

Once again thank you for your support :slight_smile:

Any concerns or ideas please let me know.

Thank you.


Thanks for sharing the files. We will investigate the issue accordingly and let you know as soon as we have some updates.