我想添加一个形状到退出组,我放在一个主模板,其中alread包含约4个儿童形状在Visio2013与C#。
详细地说,我想向DBEntity添加更多的属性。到目前为止,我使用了形状类的parent-Property,但是这总是破坏现有的组,使其不可用/不可分组。
using VisioApi = Microsoft.Office.Interop.Visio;
VisioApi.Application application = new VisioApi.Application();
application.Documents.Add(templatePath);
VisioApi.Document crowStencil = application.Documents["DBCROW_M.vssx"];
VisioApi.Master entityMaster = crowStencil.Masters.get_ItemU("Entity");
VisioApi.Master attributeMaster = crowStencil.Masters.get_ItemU("Attribute");
VisioApi.Page page = application.Documents[1].Pages[1];
VisioApi.Shape entityShape = page.Drop(entityMaster, 5.0, 5.0);
VisioApi.Shape attributeShape = page.Drop(attributeMaster, 5.0, 5.2);
// After assigning parent, entityShape isn't grouped anymore
attributeShape.Parent = entityShape;如何用正确的方式做这件事?
更新:正如响应中提到的,Crow使用容器而不是组。
发布于 2016-02-14 23:58:30
“乌鸦脚”形状在Visio 2013中使用“容器”实现。因此,您应该使用容器API来操作这些。不要使用Parent或分组函数,这些不是您要寻找的函数。而是使用ContainerProperties,特别是InsertListMember。
了解更多有关visio容器在这里的内容以及如何操作它们:https://msdn.microsoft.com/en-us/library/office/ff959245.aspx
立即解决您的挑战:
// add one attribute to entity shape
entityShape.ContainerProperties.InsertListMember(attributeShape, 0);请注意,M$可能有一些计划来恢复旧的ER图,这可能导致需要重新工作ER-形状。意味着,AFAIU ER图应该是最终用户解决方案,而不是被编程操作--你似乎是在跨越一条仅仅是凡人不应该跨越的界限:)
https://stackoverflow.com/questions/35397813
复制相似问题