473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

disable/enable menu items

Hi,
Can someone please help me. I've got a strang problem in Visual Studio
2005

I've created a windows application, using an MDI form and top menu.
When a menu item is clicked, a new instance of a form appeirs.
At the same time, i'm disabling the menu item to prevent opening it
again.
I've placed some code in the new form, so when it is closed, it should
re-enable the menu item in the main MDI-form.
Unfortunately, the menu-item will not re-enable.

The code I'm using in the main form for opening the new for and
disabling the menu item ...
ViewMovieToolStripMenuItem.Enabled = False
Dim objForm As dataform
objForm = New dataform
objForm.MdiParent = Me
objForm.Show()
The code I'm using in the new form ...
Private Sub dataform_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
frmMain.ViewMovieToolStripMenuItem.Enabled = True
End Sub
Many thanx

john
Aug 26 '06 #1
1 3691
On Sat, 26 Aug 2006 10:18:32 GMT, "John Devlon" <jo********@hotmail.comwrote:
>Hi,
Can someone please help me. I've got a strang problem in Visual Studio
2005

I've created a windows application, using an MDI form and top menu.
When a menu item is clicked, a new instance of a form appeirs.
At the same time, i'm disabling the menu item to prevent opening it
again.
I've placed some code in the new form, so when it is closed, it should
re-enable the menu item in the main MDI-form.
Unfortunately, the menu-item will not re-enable.

The code I'm using in the main form for opening the new for and
disabling the menu item ...
ViewMovieToolStripMenuItem.Enabled = False
Dim objForm As dataform
objForm = New dataform
objForm.MdiParent = Me
objForm.Show()
The code I'm using in the new form ...
Private Sub dataform_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
frmMain.ViewMovieToolStripMenuItem.Enabled = True
End Sub
Many thanx

john
It looks like from what you posted, you may have more than one instance of objForm.

1) Channge:
Dim objForm As dataform
objForm = New dataform

to:
Dim objForm as New dataform
2) On the face of it, you used the FormClosed event in dataform, so one assumption here is that the
instance of the dataform is not visible, but not closed - FormClosed event not firing for other
reasons not shown in your posted code.
Try using the dataform_FormClosing event to enable the menu item.

Gene
Aug 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bob Bedford | last post by:
I create checkboxes using datas from a database (with PHP). I store all values in an array, as I must pass this value like a Form value. Now, in some cases, when a checkbox is selected, I must...
3
by: Stilgar[bbs.isca.uiowa.edu] | last post by:
Here's my newbie question: I have several VB forms which are all inherit a standard template form that I made. In my template form, I added a menu bar with some generic cut, copy, and paste...
5
by: Brian Henry | last post by:
I have a form with a main menu on it (mdi parent form) and i have a child form with a menu and I am mergeing the menus together for the menu called reports.. now when i do this they merge just...
6
by: Agnes | last post by:
In my menu, there is invoice,customer .... etc As the user click 'Invoice' , the invoice form is load, then I want to disable the "Invoice" menu in the Menuitem, ,so the user can only new one...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
4
by: John Devlon | last post by:
Hi, Can someone please help me. I've got a strang problem in Visual Studio 2005 I've created a windows application, using an MDI form and top menu. When a menu item is clicked, a new instance...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, friends, I am using C#.net 2005 to create a windows application. It has menu items, such as File, etc. Under File, there are more menu items, such as New Files, Working Files, etc. Under...
56
by: Deepan HTML | last post by:
Hi All, Currently i am working in a framed environment where i have divided the window as 20% and 80% and the 20% is used for navigation purpose and right frame for displaying the orignal content....
2
by: Naushad | last post by:
Hi all, I am using the countinous form. I want to Enable/Disable the some fields for perticular records as per the following condition when open the form. I have written this code in "On Current...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.