Search code examples
c#mmc

How to show children of ScopeNode in MMC C# application?


We are developing Microsoft Management Console windows form application in C#. We have successfully added scopenode and children to that scopenode as follows

        this.RootNode = new ScopeNode();
        this.RootNode.DisplayName = "Poseidon Security Manager";
        FormViewDescription fvd = new FormViewDescription();
        fvd.DisplayName = "Poseidon Security Dashboard";
        fvd.ViewType = typeof(ServiceViewForm);
        fvd.ControlType = typeof(ServiceUserControl);
        //RootNode.ViewDescriptions.Add(fvd);                                   

        ScopeNode scopeNode = new ScopeNode();
        scopeNode.DisplayName = "Configuration Management";
        ScopeNode sNode = new ScopeNode();
        sNode.DisplayName = "Endpoints";
        scopeNode.Children.Add(GetDeviceTypeList(sNode));
        RootNode.Children.Add(scopeNode);

        RootNode.ViewDescriptions.Add(new FormViewDescription() { ControlType = typeof(ServiceUserControl), ViewType = typeof(ServiceViewForm), DisplayName = "Poseidon Security Dashboard", Tag = scopeNode });

In ServiceUserControl we have one button. On that button click event we want to show the children of "Poseidon Security Manager". It means we want to expand "Poseidon Security Manager" scopenode and show "Configuration Management" scopeNode. How to do that ? Can you please provide solution ?


Solution

  • In the user control we need to call object of FormView in one of the method as follows

     formView.SelectScopeNode(selectedScopeNode);
    

    It automatically expands all the parent node hirarchy of selectedScopeNode and selectedScopeNode will get highlighted