Hi, I want to make an application that have a treeview and a list of properies to modify another application controls RRS feed

  • Question

  • The Application I had in Concept has a treeview where I can navigate trought Windows and Controls (Panel, Button, TextBox, PictureBox, etc.) of all the running Windows on my PC and can change thier properties or even remove or add others. If it is possible I also would like to add and remove handles.

    Thank You for providing me Feedback

    Tuesday, January 15, 2019 1:47 PM


  • Yes it's possible using Reflection to get methods, properties of a class (which a form is a class). It's not a simple task though as you would segment your code between properties and method then events where events would prove to be the more difficult of the three.

     While gathering information you would need assertion to ensure a value of something you are getting actually has a value and is not null/nothing.

    The basics are to use GetType of an object, using GetProperties method for a type use a combination of flags e.g.

    Where in this case someObject is the object you want properties for that can be a class of a form or controls on a form.

    For Each pi As PropertyInfo In t.GetProperties(BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic) 
        ‘ Get the name and value of the property 
        fieldName = pi.Name
        ‘ Get the value of the property 
        propertyValue = pi.GetValue(someObject, Nothing) 
        Console.WriteLine(fieldName & ": " & 
          If(propertyValue Is Nothing, "Nothing", propertyValue.ToString)) 

    When collecting information you will need to have concrete classes to hold information collected.

    So yes it can be done but a decent amount of code will be needed with knowledge of how reflection works in tangent with the objects you are traversing.

    Lastly, I don't have any code samples so no need to ask for me.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by valaki2018 Saturday, February 2, 2019 11:01 PM
    Tuesday, January 15, 2019 2:24 PM