Hi,
Can I display the resulted objects to the program user in a 'tree view' as that appears in the debugging window 'Autos'
Thanks,
Aya.
Hi,
Can I display the resulted objects to the program user in a 'tree view' as that appears in the debugging window 'Autos'
Thanks,
Aya.
Display results to the end user as it appears in the 'Autos' window of debugging
ListrCZ
Ok,
My application is for a research in the 'Computer Science' domain , and the user also will be a professional programmer.
I need to explore all properties of specific objects to see the qualification of the application's results.
Thanks,
Aya.
NetPochi
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
propertyGrid1.SelectedObject = this;
}
}
Expand on this by setting the SelectedObject property to your own object...
Nageshwar
Thank you Mr. nobugz, but can I get more explanation please.
Thanks,
Aya.
sqlhiker
Ok,thank you.
I have tried it but:
when I use the sentence: Object2Tree(this, treeView1);
it results the tree of the Form , when I use my own object instead of 'this',the resulted tree is empty and the value of the 'props' in
PropertyInfo[] props = t.GetProperties();
= {Dimensions:[0]}
Here is the first lines of my own class 'TextPreprocessingClass' :
I need to show the values of that properties , such as tagsTable, InitialNodesTable ,.......
as I saw in the Autos window.
I am so sorry for my insipid request,
Thanks in advance,
Aya.
Tadwick
Yes,
It is an instance of user defined class that has its own properties.
The ZMan
georgeob
Christie Myburgh
Klaus Aschenbrenner
Ok, I have tried that, it displays the properties of the form or a specific button , but when I try to set the SelectedObject to my own object , it displays nothing!!
Am I do something wrong
Aya.
CaRNaGe_46038
// Display the fields
FieldInfo[] fields = t.GetFields();
foreach (FieldInfo fld in fields){
string fldvalue = " ";
try {
object value = fld.GetValue(obj);
if (value == null) fldvalue = "null";
else fldvalue = value.ToString();
}
catch (Exception ex) {
fldvalue = " " + ex.Message;
}
root.Nodes.Add(fld.Name + ": " + fldvalue);
}
DavidThi808
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
Object2Tree(this, treeView1);
}
public static void Object2Tree(object obj, TreeView tree) {
// Displays properties of <obj> in <tree>
Type t = obj.GetType();
TreeNode root = tree.Nodes.Add(t.Name);
// Display the properties
PropertyInfo[] props = t.GetProperties();
foreach (PropertyInfo prop in props) {
string propvalue = " ";
try {
if (!prop.CanRead) propvalue = "Write only";
else {
object value = prop.GetValue(obj, null);
if (value == null) propvalue = "null";
else propvalue = value.ToString();
}
}
catch (Exception ex) {
propvalue = " " + ex.Message;
}
root.Nodes.Add(prop.Name + ": " + propvalue);
}
}
}
jiao
Thank you for your reply.
But I need more explanation please.
Thanks,
Aya
ccg420104
Biju S Melayil
Take a look at the PropertyGrid control too.