开发者

How can I hide the inherited menu strip?

I've got a form that needs to inherit a base form. The problem is that the base form has a menu strip. The form I'm working on should not have any kind of menu on it.

How can I hide the inherited menu strip? Alternatively, how can I exchange the inherited menu for something I construct开发者_高级运维 myself in the new form?


In the base form class, extract the menu strip creation code from InitializeComponent() into a virtual method, and then override that method in the new form. The drawback of this is you lose visual designer support for the menu in the base form.


I found another way, which I actually ended up using.

If you don't need to show the menu again in that particular form, you can initialize all the components as usual. Then simply make a public method like HideMainMenu() in your base class, that you call after all Init's are run, which only does this:

Public Sub HideMainMenu()
    Me.Menu = Nothing
End Sub

You could probably show the menu again by doing

Public Sub ShowMainMenu()
    Me.Menu = Me.myPrivateMainMenu
End Sub

But I haven't tried that...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜