473,385 Members | 1,863 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
4 1683
Private Sub dataform_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
I think you should use 'Handles MyBase.Closed'.
Aug 26 '06 #2
Hi,

MyBase.closed doesn't work ... I've also tried MyBase.FormClosed ....

The event itself works fine... I've tested it with a messagebox and it works
....
But with a menu-item, it does nothing ... I think sometings wrong with the
code for re-enabling the menu-item, or it's a bug in vb...

But many thanks for your input ...

John

I think you should use 'Handles MyBase.Closed'.

Aug 26 '06 #3

Hi,

I've found the problem ...

On my first form I've created some code for opening the mdi-form

Dim objForm As frmMain
objForm = New frmMain
objForm.MdiParent = Me

when using this code on new form launched from the MDI form ..

frmMain.ViewMovieToolStripMenuItem.Enabled = True

it doesn't work

using this code on the first form, it works..

frmMain.Show()
So the origine of the problem was something simple...


John
Aug 26 '06 #4
John,

I am not sure if it is in 2005 the same, but the form.Isdisposed property is
one of the best hidden properties.

http://windowssdk.msdn.microsoft.com...sdisposed.aspx

Can you try that?

If this is not enough information than reply

I hope this helsp,

Cor

"John Devlon" <jo********@hotmail.comschreef in bericht
news:ur********************@phobos.telenet-ops.be...
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 #5

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???
1
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: coolarian | last post by:
Hi, I have an C# MDI application. There are three mdi childs, mdiFormA, childB and childC. childA is loaded in the parent by default as below: private void TestingMenu_Load(object sender,...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.