disable/enable menu items

J

John Devlon

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
 
G

Guest

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'.
 
J

John Devlon

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
 
J

John Devlon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top