Hi
I am getting an issue in expanding a treeview within the MDI Form.. When I try to run code to expand a treeview from normal form, it works perfectly. As soon as I try to call that form from a MDIForm it fails to expand by default.
Main Program Codestatic class Program{/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);//Application.Run(new CDIM.Tracker.Modules.frmDashboard());Application.Run(new TrackerMDI()); //Calling MDI}}
MDI Form codepublic TrackerMDI(){InitializeComponent();
Form1 objForm1 = new Form1(); //This is the form that has treeviewobjForm1.Visible = true;objForm1.MdiParent = this; // this is making the treeview not to expandobjForm1.Show(); //Shows treeview without expanding any node}
Form1 Code:public Form1(){InitializeComponent();}
protected override void OnLoad(EventArgs e){base.OnLoad(e);InitializeTreeView();}
// Populates a TreeView control with example nodes. private void InitializeTreeView(){treeView1.BeginUpdate();treeView1.Nodes.Add("Parent");treeView1.Nodes[0].Nodes.Add("Child 1");treeView1.Nodes[0].Nodes.Add("Child 2");treeView1.Nodes[0].Nodes[1].Nodes.Add("Grandchild");treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("Great Grandchild");treeView1.Nodes.Add("Parent");treeView1.Nodes[1].Nodes.Add("Child 1");treeView1.Nodes[1].Nodes.Add("Child 2");treeView1.Nodes[1].Nodes[1].Nodes.Add("Grandchild");treeView1.Nodes[1].Nodes[1].Nodes[0].Nodes.Add("Great Grandchild");treeView1.EndUpdate();treeView1.ExpandAll();}
What can be the problem with MDIChild???