Closing form while opening

JFK

Member
Joined
Nov 28, 2005
Messages
20
Location
Czech Republic
Programming Experience
5-10
I need solve problem with my MDI and child forms. When user select (thru menu), which child form he wants to show, I would like to check, if user has permission for it. If not, dont want to show child form.

I'm not shure, that I am going the right way, but in VB6 it worked OK. Not in VB.NET.


1) I call frmChildForm.show from MDI.menu_onClick event.
2) in frmChildForm_Load i check for permissions and call Me.Hide for frmChildForm object
3) in frmChildForm_Activated I call Me.Close for frmChildForm object


After that, I receive error:
***************************
An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: Cannot call Close() while doing CreateHandle().
***************************
:confused:
What is wrong? Any ideas?

Any advice will be appreciated.

Regards. #JFK
 
Are u talking about this?
 

Attachments

  • menuitem.png
    menuitem.png
    13.7 KB · Views: 143
Ok, i beleive you will find this useful. namely, by using a HashTable we refer to the corresponding MenuItem, and we can enable or disable it!
Take a look at the link below or moreover get the attached project from the provided link (somewhere in the middle of the page)
http://www.devcity.net/newsletter/archive/devcity/devcity20050125.htm
to find the code press Ctrl+F and enter "Disable menu items through their names"


HTH
Regards ;)
 
:)

Thank You for your effort, but I have already solve it.

This could be OK, but I have already designed my MenuItems (in design time), so I should make all my menus again and it could be more work for me.

The easiest way for me was to make my own Class (as I mentioned above) and add one more own property in it. This property I can use for storing neccesary data.

All I have to do now is, that I have to persuade MainMenu object to use new MenuItem class instead of original. And it's all.

Thanks again.

Have a goog day.

Ragards #JFK
 
Back
Top