Click here to Skip to main content
6,594,088 members and growing! (15,437 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate

Object Inspector

By Sir Zeppa'Man

A complete Object Inspector.Some cool features added.
C#, Windows, .NET, Visual Studio, Dev
Posted:1 Dec 2005
Updated:27 Mar 2006
Views:23,717
Bookmarked:30 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
19 votes for this article.
Popularity: 5.26 Rating: 4.12 out of 5
1 vote, 5.3%
1
2 votes, 10.5%
2
1 vote, 5.3%
3
2 votes, 10.5%
4
13 votes, 68.4%
5

Sample Image - ObjectInspector.jpg

What's new?

In this update I add some coll features like:
  • Recompiled for framework2
  • Revisited the graphic interface
  • Added a info panel on the footer
  • more properties are exposed
  • Some refacrtoring methods are exposed
  • added the show method list
  • added the show type attribute
  • added the preview Control in new Form

Introduction

The framework give us a usefull component to Show informations about a control. I'm speaking about The property grid.It's a beautiful control but unfortunately it dont list controls ,so the user can select a specific control.I try to resolve thi probem with thi control

Object Inspector

Object inspector is an avanced proprerty grid that list and show every control on the form. Whe user selets one item, Object Inspector show all his properties.An alternative to list all the properties is to click the "Show properties button" that show tis is the form:

propertylist.jpg


Finding all components

On loading(or when user call reload ) the control scan the form to find every control. The search is obviously recoursive and my solutions(maybe not the best...) is shown below:
public void FindChild(Control par)
        {


            foreach (Control cc in par.Controls)
            {
                
                    if (cc.Name!=null&&cc.Name!="")
                        this.comboBox1.Items.Add(cc.Name);
                    if(cc.Controls.Count>0)
                        FindChild(cc);
                    
                
            }

        }
        public void FindEach()
        {
            this.comboBox1.Items.Clear();

           if (this.Parent!=null&&this.Parent.Controls.Count>0)
            foreach (Control cc in this.Parent.Controls)
            {
                this.comboBox1.Items.Add(cc.Name);
                if (cc.Controls.Count > 0)
                    FindChild(cc);

            }

        }

Finding the selected component

When user select a controls on the list ,this control search on the form's control the right object .Also in this case I use a recoursive search.When the right object has found I send it to the Property grid to show all it's feature.
public Control FindChildByName(ref string name,Control par)
        {

            Control c=null;
            foreach (Control cc in par.Controls)
            {
               
                    
                     if(cc.Name==name)
                      return cc;
                     
                     if(cc.Controls.Count>0)
                     {
                         c=    FindChildByName(ref name,cc);
                         if (c!=null)
                             return c;
                     }
                
            }
            return null;
        }
        public Control FindObjectByName(string name)
        {
            
           Control c=null ;
           if (this.Parent!=null&&this.Parent.Controls.Count>0)
            
               foreach (Control cc in this.Parent.Controls)
            {
               
                if(cc.Name==name)
                    return cc;
                
                if (cc.Controls.Count > 0)
               {
                         c=    FindChildByName(ref name,cc);
                         if (c!=null)
                             return c;
               }

            }
           return null;
        }

Credits

This is only one of the possible solutions.Maybe isn't the better,but I think that's simple and fast.For every advice,question or problem please contact me . If You would see my other work please visit my home page: http://zeppaman.altervista.org



License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sir Zeppa'Man


Member

Location: Italy Italy

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
JokeCompatible with framework 1 and 2 PinmemberSir Zeppa'Man9:58 28 Mar '06  
GeneralQuite similar to ... PinmemberTutu2:15 7 Dec '05  
GeneralRe: Quite similar to ... PinmemberSir Zeppa'Man4:06 9 Dec '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Mar 2006
Editor:
Copyright 2005 by Sir Zeppa'Man
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project