accessing properties of the mdiParent from the child
-
here is what I have:
//the property for the parent form in the child form private frmMain ParentForm { get{return (frmMain)this.MdiParent;} } //the load form method private void frmEventList_Load(object sender, System.EventArgs e) { //set the form status ParentForm.StatusBar = "Searching for events"; //StatusBar is a property in the frmMain that sets the status bar LookupEvents(DateTime.Now, DateTime.Now); ParentForm.StatusBar = "Ready222"; }
using this the Parent forms status bar text does not change. No exception is thrown indiciating that there is somthing wrong with the code. I have just recently had to change over from VB.NEt so it may be something simple. Thanks for the help -
here is what I have:
//the property for the parent form in the child form private frmMain ParentForm { get{return (frmMain)this.MdiParent;} } //the load form method private void frmEventList_Load(object sender, System.EventArgs e) { //set the form status ParentForm.StatusBar = "Searching for events"; //StatusBar is a property in the frmMain that sets the status bar LookupEvents(DateTime.Now, DateTime.Now); ParentForm.StatusBar = "Ready222"; }
using this the Parent forms status bar text does not change. No exception is thrown indiciating that there is somthing wrong with the code. I have just recently had to change over from VB.NEt so it may be something simple. Thanks for the helpare u sure ur frmEventList_Load is getting callled? Try putting a break point in the event handler and following ur code. U should see where ur code is failing to do what u expect. What u've posted looks fine but we're missing a lot more that could be wrong.
-
are u sure ur frmEventList_Load is getting callled? Try putting a break point in the event handler and following ur code. U should see where ur code is failing to do what u expect. What u've posted looks fine but we're missing a lot more that could be wrong.
-
I have put the line break in the load event. It steps through fine, but when I call on the StatusBar property in the commend window it says: error: 'ParentForm.StatusBar' does not exist but how would the parent mdiForm not exist? Thanks for the help.
-
Here is the form load for the mdiParent
private void frmMain_Load(object sender, System.EventArgs e) { //populate the status bar StatusBarPanel status = new StatusBarPanel(); //status.Text = "Ready"; status.AutoSize = StatusBarPanelAutoSize.Spring; sbrStatus.Panels.Add(status); sbrStatus.ShowPanels = true; //attach the child window Form frmEventList = new frmEventList(); frmEventList.MdiParent = this; frmEventList.WindowState = System.Windows.Forms.FormWindowState.Maximized; frmEventList.Show(); }
Thanks for the help -
Here is the form load for the mdiParent
private void frmMain_Load(object sender, System.EventArgs e) { //populate the status bar StatusBarPanel status = new StatusBarPanel(); //status.Text = "Ready"; status.AutoSize = StatusBarPanelAutoSize.Spring; sbrStatus.Panels.Add(status); sbrStatus.ShowPanels = true; //attach the child window Form frmEventList = new frmEventList(); frmEventList.MdiParent = this; frmEventList.WindowState = System.Windows.Forms.FormWindowState.Maximized; frmEventList.Show(); }
Thanks for the helpI cant see what is wrong with ur code...at least not to the point where the command line would give u the error ur stating, unless ur querying ParentForm.StatusBar when its out of scope although I doubt that. Whats even wierder is that, if I'm not misunderstanding, when ur application runs, your not getting any exception. Just to cover all possibilities, I'll ask u to post some more code once again...sorry :p : Please post ur StatusBar property.