1

I'm new to programming and have a problem in VB.net

For a project with a couple of forms, I wanted to work with a module that automatic loads a menu (toolstrip) in a form (kind of CSS in web develop). This works for the first time but if I repeat the action the menu disappears. (eg drivers > Taxi > drivers).

I think the error is when I (re)load the form.

Here is my code

Module code

Declaration:

Public tsbdrivers, tsbTaxi As New ToolStripButton
Public tsMenu As New ToolStrip

Properties of tsMenu

With tsMenu
        .Dock = DockStyle.Left
        .Text = "Navigatie, klik op knoppen om iets raad te plegen"
        'toolstrip bevolkeren
        .Items.Add(tsbchauffeurs)
        .Items.Add(tsbTaxi)
    End With
    'probs drivers
    With tsbdrivers
        .DisplayStyle = ToolStripItemDisplayStyle.Image
        .Image = Taxi2014.My.Resources.Resources.Chauffeurs
        .ImageScaling = ToolStripItemImageScaling.None
        .Text = "Raadpleeg uw chauffeurs en/of werknemers."
        AddHandler .Click, AddressOf DriverOpen
    End With
    'probs Taxi
    With tsbTaxi
        .DisplayStyle = ToolStripItemDisplayStyle.Image
        .Image = Taxi2014.My.Resources.Resources.Wagens
        .ImageScaling = ToolStripItemImageScaling.None
        .Text = "Raadpleeg uw wagens."
        AddHandler .Click, AddressOf TaxiOpen
    End With
End Sub

(Image are imported images)

Public subs

Public Sub DriverOpen()
    HideAll()
    Frmdriver.Show()
End Sub

Public Sub TaxiOpen()
    HideAll()
    Frmdriver.Show()
End Sub

 Public Sub HideAll()
    FrmMenu.Hide()
    FrmDrivers.Hide()
    frmTaxi.Hide()
End Sub

Code in the 2 forms

Private Sub frmTaxi_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'Menu toevoegen

    Afbeeldingeninladentoolstrips()
    Me.Controls.Add(tsMenu)
End sub

I don't know if it matters, but for most of my forms I use datasets. Can anyone please help me? I will thank you a thousand times. :D

0 Answers0