treeview node visible

Hİ;

I want to treeview node visible (form load) for c# but i don't know please help me.
Gökmen Anıl YılmazStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
Please share whatever code you got already. Whatever mentioned is just an opinion and very abstract to comment on.
0
Gökmen Anıl YılmazStudentAuthor Commented:
I want any TreeView nodes to be invisible when the form is loaded
0
AndyAinscowFreelance programmer / ConsultantCommented:
Actually at the form load the form itself is not visible.  You need to explain more clearly what you want / what you have done that doesn't work.
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Gökmen Anıl YılmazStudentAuthor Commented:
for example ;

if login is admin ,  Form2.node will see, if login not admin Form2.node doesnt see?
0
MishaProgrammerCommented:
There is a property "visible" from each node of treeView. But this property is read only.
If you want to make invisible one node (not all treView), you can inherit from tree node and create your own behaviour.

public class RootNode : TreeNode
{
    public List<ChildNode> ChildNodes { get; set; }

    public RootNode()
    {
        ChildNodes = new List<ChildNode>();
    }

    public void PopulateChildren()
    {
        this.Nodes.Clear();

        var visibleNodes = 
            ChildNodes
            .Where(x => x.Visible)
            .ToArray();

        this.Nodes.AddRange(visibleNodes);
    }

    //you would use this instead of (Nodes.Add)
    public void AddNode(ChildNode node)
    {
        if (!ChildNodes.Contains(node))
        {
            node.ParentNode = this;
            ChildNodes.Add(node);
            PopulateChildren();
        }
    }

    //you would use this instead of (Nodes.Remove)
    public void RemoveNode(ChildNode node)
    {
        if (ChildNodes.Contains(node))
        {
            node.ParentNode = null;
            ChildNodes.Remove(node);
            PopulateChildren();
        }

    }
}

public class ChildNode : TreeNode
{
    public RootNode ParentNode { get; set; }
    private bool visible;
    public bool Visible { get { return visible; } set { visible = value;OnVisibleChanged(): } }
    private void OnVisibleChanged()
    {
        if (ParentNode != null)
        {
            ParentNode.PopulateChildren();
        }
    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
>>if login is admin ,  Form2.node will see, if login not admin Form2.node doesnt see?

If login is not admin - do not add Form2.node to the treeview when filling the data
0
MishaProgrammerCommented:
There is no activity from author
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
TreeView

From novice to tech pro — start learning today.