none
How to share a menu bar between two forms? RRS feed

  • 問題

  • Hey, everybody.

    I'm writing a small software similar to the calculator in Windows, the calculator in Windows has a [B]menu bar[/B]; in the menu bar, you can find "scientific" and "standard" mode; once you select different mode, your form will be changed, but the two forms still share the same menu bar.

    I want to create the same effect of this:
    1. Two forms, only one is visible at any time
    2. The menu bar on the top of the two forms should be shared between these forms

    I just started learning VB for 2 weeks, I'm not sure my thinking can be achieved by VB, if not, please inform me the right way to do it.

    Please give details since I'm just a beginner.

    Thank you very much for your time in advance
    2010年6月17日 下午 12:53

解答

  • Hi,

    you can reference it

    Public Class Form1
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f As New Form
        f.Controls.Add(Me.MainMenuStrip)
        f.MainMenuStrip = Me.MainMenuStrip
        f.Show()
      End Sub
    End Class
    


    謙卑學習,持之以恆,才能不斷的Level Up http://www.dotblogs.com.tw/larrynung/
    2010年6月17日 下午 03:09

所有回覆

  • Refrence the MSDN Libraty

    [Multiple-Document Interface (MDI) Applications ]


    以下是簽名檔, 請勿沒事對號入座
    MSDN 文件庫很重要
    回應幫助你的人是一種禮貌, 良好的禮貌有助於激發大家對你問題回應的熱情
    進步的人會找尋自己程式中的缺點,半桶水則把自己程式的錯誤推到不相干事物的身上
    2010年6月17日 下午 02:59
    版主
  • Hi,

    you can reference it

    Public Class Form1
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f As New Form
        f.Controls.Add(Me.MainMenuStrip)
        f.MainMenuStrip = Me.MainMenuStrip
        f.Show()
      End Sub
    End Class
    


    謙卑學習,持之以恆,才能不斷的Level Up http://www.dotblogs.com.tw/larrynung/
    2010年6月17日 下午 03:09
  • 谢谢您的回答!
    2010年6月18日 上午 10:03