there is mdi parent form that contain the menustrip initially the menu strip is disabled after the user successfully login from child login form.. after the successful login i need to enabled the mdi parent menu strip
what i have tried so far is something like this but it is not working.
if (username == validUsername && password == validPassword)
{
this.mdicontainer.menustrip.enabled = false;
}
what is way to access the mdiparent control from the child form..
Changing properties of main form from child form is a kind of bad manner for me. How about creating a login dialog form and using it just for requesting login and password? The default login form scenario is quite simple:
Here are some helpful links on creating login forms:
Suppose you have a MDI form called with your own custom property called and a menu strip control called : 的MDI表单, 包含您自己的名为的自定义属性和一个名为的菜单控件:
// Property variable
private bool _MenuStripEnabled = true;
// Custom property
public bool MenuStripEnabled
{
get {
return _MenuStripEnabled;
}
set {
_MenuStripEnabled = value;
this.MainMenuStripControl.Enabled = value;
}
}
Then to call it from a child form, you just do this:
(this.MdiParent as MDIMaster).MenuStripEnabled = false;
The part reassigns the generic MdiParent as your specific form type, allowing you access to your custom property. 部分将通用MdiParent重新指定为您的特定表单类型,允许您访问自定义属性。
;-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.