none
Menu strip to form RRS feed

  • Question

  • I haven't developped in VB form quite some time. I can't sfind the create new form option in the any menu.

    I 've created a menu strip and I whant that when I click on an element in the menu it takes me to the corresponding form.

    Thursday, December 20, 2018 7:54 AM

All replies

  • Hi,

    Do you want to Click to open form?

     Private Sub FormAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FormAToolStripMenuItem.Click
            Dim FA As Form2 = New Form2
            FA.TopLevel = True
            FA.Show(Me)
        End Sub
    
        Private Sub FormBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FormBToolStripMenuItem.Click
            Dim FB As Form3 = New Form3
            FB.TopLevel = True
            FB.Show(Me)
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 20, 2018 8:40 AM

  • Hi,

    Yes, I whould like to it on click.

    I'm aware of the .Show() function. I've tried to programme a form with completed ui with this:

    Public Function funcCreateForm()
    On Error GoTo ErrorPoint
    Dim frm As Form
    Dim ctlLabel As Control
    Set frm = CreateForm
    frm.Caption="Parameters"
    frm.AutoCenter = True
    frm.NavigationButtons = 0
    frm.RecordSelectors = 0
    frm.ScrollBars = 0
    frm.Width = 5760
    frm.Section(0).Height = 2880
    frm.Section(0).BackColor = -2147483633
    frm.AllowEdits = False
    frm.AllowDeletions = False
    frm.AllowAdditions = False
    frm.AllowFilters = False
    frm.ShortcutMenu = False
    frm.ViewsAllowed = 0

    Set ctlLabel = CreateControl(frm.Name, acLabel, _
    , , "parameters", 1440, 720, 2880)
    ' Save and close the form
    DoCmd.Close acForm, frm.Name, acSaveYes
    ExitPoint:
    Exit Function
    ErrorPoint:
    MsgBox "The following error has occurred:" _
    & vbNewLine & "Error Number: " & Err.Number _
    & vbNewLine & "Error Description: " _
    & Err.Description _
    , vbExclamation, "Unexpected Error"
    Resume ExitPoint
    End Function

    Thursday, December 20, 2018 10:19 AM
  • Hi,

    like this?

    Public Class Form1
    
        Public Function CreateForm(ByRef s As String) As Form
            Dim f As Form = New Form
            f.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            f.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            f.ClientSize = New System.Drawing.Size(547, 266)
            f.Name = s
            f.Text = s
            Return f
        End Function
    
        Private Sub FormAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FormAToolStripMenuItem.Click
            CreateForm("FormA").Show()
        End Sub
    
        Private Sub FormBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FormBToolStripMenuItem.Click
            CreateForm("FormB").Show()
        End Sub
    End Class
    


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 21, 2018 1:43 AM