Search code examples
c#shapesvisio

How to selecte the child shape in Visio(C#)


I'm trying to select the child shape, but It's impossible. My code doesn't works only child shape.

var app = await FlipClass.GetVisioApplicationAsync();
var doc = app.ActiveDocument;
var page = app.ActivePage;

Visio.Selection selection = page.Application.ActiveWindow.Selection;
Debug.WriteLine(selection.Count);

For example, enter image description here In the following situations, output is 1. It works good. However, enter image description here In the following situations, output is 0. The child shape was not selected.

Please, help.

I want to access the child shape to obtain the attribute value.


Solution

  • Try this

    Visio.Selection selection = page.Application.ActiveWindow.Selection;
    selection.IterationMode = 0;
    Debug.WriteLine(selection.Count);
    

    if it works then read about selection IterationMode and selection PrimaryItem