What's New?
In this update, I add some cool features like:
- Recompiled for framework2
- Revisited the graphic interface
- Added an info panel on the footer
- More properties are exposed
- Some refactoring methods are exposed
- Added the show method list
- Added the show type attribute
- Added the preview Control in new Form
Introduction
The framework gives us a useful component to show information about a control. I'm speaking about the property grid. It's a beautiful control but unfortunately it does not list controls, so the user can select a specific control. I try to resolve this problem with this control.
Object Inspector
Object inspector is an advanced property grid that lists and shows every control on the form. When the user selects one item, Object Inspector shows all its properties. An alternative to list all the properties is to click the "Show properties button" that shows this is the form:
Finding All Components
On loading (or when user calls reload), the control scans the form to find every control. The search is obviously recursive and my solutions (maybe not the best...) are 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 selects a controls on the list, this control searches for the right object on the form's control. Also in this case, I use a recursive search. When the right object is found, I send it to the Property grid to show all its features.
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 it is not the best one, but I think that's simple and fast. For any advice, question or problem, please contact me. If you would like to see my other work, please visit my home page at http://zeppaman.altervista.org.
I'm senior developer and architect specialized on portals, intranets, and others business applications. Particularly interested in Agile developing and open source projects, I worked on some of this as project manager and developer.
My programming experience include:
Frameworks \Technlogies: .NET Framework (C# & VB), ASP.NET, Java, php
Client languages:XML, HTML, CSS, JavaScript, angular.js, jQuery
Platforms:Sharepoint,Liferay, Drupal
Databases: MSSQL, ORACLE, MYSQL, Postgres