0

I am working with visual basic. How do I get all the .exe files to show as buttons in a panel in my main form ? I am currently using a static method that only allows me to launch applications when I click a button with the application icon . all the buttons and functions are set in the code to this method as shown in this code .

    Public Class AppSelectorMain

    Private Sub MRDButton_Click(sender As Object, e As EventArgs) Handles MRDButton.Click
        Try
            Shell("D:\projects\VisualBasicAFMRD\AFMRD\bin\Debug\AFMRD.exe", vbNormalFocus)

        Catch ex As Exception

            msgbox("app not available")

        End Try
    End Sub
    Private Sub AoFurutusButton_Click(sender As Object, e As EventArgs) Handles AoFurutusButton.Click
        Try
            Shell("D:\projects\VisualBasic\project1\project1\bin\Debug\project1.exe", vbNormalFocus)
        Catch ex As Exception
            msgbox("app not available")

        End Try
    End Sub
End Class

this method is great for some occasions and you can make a very nice App Selection panel .

I Would like to be able to have all .exe files appear in my form during startup similar to the windows task bar . So I'm guessing I will have to create a shortcut .exe file for each application and place them all in 1 main folder. the shortcut exe files is created during the setup of the application by the user and automatically gets placed in the main folder . the main folder is created during the setip of the users first application produduced under my trademarked name "Alternate Futue" once set up all following alternate future applications will find and populate the main folder an exe file for its application.

how do I now get those exe files to be displayed as buttons that can launch the applications ? any ideas ?

Adrian
  • 2,825
  • 1
  • 22
  • 32

1 Answers1

1

I'm assuming WinForms here, so Just add a ToolStrip control and Dock it to the bottom of your form.

Add some ToolStripButtons, set the Image property to something meaningful.

Then peform some action when each ToolStripButton is clicked:

Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
    Shell("D:\projects\VisualBasicAFMRD\AFMRD\bin\Debug\AFMRD.exe", vbNormalFocus)
End Sub

If you want to add items dynamically at runtime. Have a look at this SO question: Adding Items to ToolStrip at RunTime

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • that is the method that i displayed in my code . i'm looking to have buttons dynamically created to match the number of and types of exe files in a folder . so if i add an exe to the folder it will show up in the bar –  Jun 03 '13 at 03:50
  • @RuchmairDixon - that wasn't clear as you didn't mention a toolstrip anywhere. I have added a link on how to add items at runtime which should be what you want. – Matt Wilko Jun 03 '13 at 09:50