Invalid Conversion error
I recently upgraded a VB 6 project to .net. I'm having a problem  with this block of code:

        Dim CtrlName As System.Windows.Forms.MenuItem

        For Each CtrlName In Form1.Controls

        'Some code here

        Next CtrlName

Now this code compiles but throws the following runtime error:

Unable to cast object of type 'System.Windows.Forms.Panel' to type 'System.Windows.Forms.MenuItem.

I have a panel control on the subject form. How do I resolve this?
Thanks.

                
Invalid Conversion error
===

I recently upgraded a VB 6 project to .net. I'm having a problem  with this block of code:

        Dim CtrlName As System.Windows.Forms.MenuItem

        For Each CtrlName In Form1.Controls

        'Some code here

        Next CtrlName

Now this code compiles but throws the following runtime error:

Unable to cast object of type 'System.Windows.Forms.Panel' to type 'System.Windows.Forms.MenuItem.

I have a panel control on the subject form. How do I resolve this?
Thanks.

                