I want to do a control like vs2005 doc outline tool
-
...f is a Form Control t_ctrl; for (int i = 0; i < f.Controls.Count; i++) { t_ctrl = f.Controls[i]; TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text); t_tn.Tag = t_ctrl; self.treeView1.Nodes.Add(t_tn); addNode(t_ctrl, t_tn); } ... private static void addNode(Control ctrl, TreeNode tn) { Control t_ctrl; for (int i = 0; i < ctrl.Controls.Count; i++) { t_ctrl = ctrl.Controls[i]; TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text); t_tn.Tag = t_ctrl; tn.Nodes.Add(t_tn); if (t_ctrl.Controls.Count != 0) { addNode(t_ctrl, t_tn); } } &nb
-
...f is a Form Control t_ctrl; for (int i = 0; i < f.Controls.Count; i++) { t_ctrl = f.Controls[i]; TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text); t_tn.Tag = t_ctrl; self.treeView1.Nodes.Add(t_tn); addNode(t_ctrl, t_tn); } ... private static void addNode(Control ctrl, TreeNode tn) { Control t_ctrl; for (int i = 0; i < ctrl.Controls.Count; i++) { t_ctrl = ctrl.Controls[i]; TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text); t_tn.Tag = t_ctrl; tn.Nodes.Add(t_tn); if (t_ctrl.Controls.Count != 0) { addNode(t_ctrl, t_tn); } } &nb
You should use a foreach, and you should write a recursive method, because some controls, contain controls.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
You should use a foreach, and you should write a recursive method, because some controls, contain controls.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
Thanks for your reply I had already use the recursive method-->"addNode(Control ctrl, TreeNode tn)"
Controls inside a tool strip aren't available from the Controls property, you need to use the Items property instead.
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
-
Controls inside a tool strip aren't available from the Controls property, you need to use the Items property instead.
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
-
So if I want to make it, I need to consider all those special controls, It's not a easy thing,right?
Did anybody have idea about how display all controls in winfroms at runtime like vs2005 doc outline tool in designtime?
hwswin wrote:
It's not a easy thing,right?
As there's no common interface to access child controls, I'm afraid not.
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro