Pergunta

I'm using the below loop to add items to a Menu Item Strip dynamically on program load

For Each specs In My.Computer.FileSystem.GetFiles(My.Settings.SpecsLoc, FileIO.SearchOption.SearchTopLevelOnly, "*.pdf*")  
        SpecsToolStripMenuItem.DropDownItems.Add(IO.Path.GetFileName(specs))
    Next

This will populate the Menu item with, on average, 20 items. I've been searching on how to now open the files from the list.

Thanks

Foi útil?

Solução

The constructor can also take an event handler, so you can just add it like this:

SpecsToolStripMenuItem.DropDownItems.Add(IO.Path.GetFileName(specs), _
                                         Nothing, _
                                         Sub()
                                           Process.Start(specs)
                                         End Sub)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top