1 Replies - 828 Views - Last Post: 17 February 2013 - 11:42 PM Rate Topic: -----

#1 krazyshank   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 21-December 12

Create button for each .lnk file in a directory

Posted 17 February 2013 - 08:36 PM

Hi, in my form, there is a tool bar, one of them for external tools. By default it has no sub-buttons.
My program will come with a directory called "tools" and users will be able to place .lnk files in there and the file name will show up as a sub-button on the tool bar, and when clicked, will open the file.

This is more advanced than anything I have learned so far, so I need help accomplishing this.
So far i have simply this:

var files = Directory.GetFiles(Dir + @"tools\").Where(name => name.EndsWith(".lnk"));
            foreach (String file in files)
                //create a button for each file

Is This A Good Question/Topic? 0
  • +

Replies To: Create button for each .lnk file in a directory

#2 TheKirk   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 58
  • Joined: 10-February 13

Re: Create button for each .lnk file in a directory

Posted 17 February 2013 - 11:42 PM

Let's assume you are currently using a ToolStrip:


A ToolStrip consists out of a collection of ToolStripItem, which are held in the ToolStrip.Items property:


You can declare a new instance of the ToolStripItem class:

ToolStripMenuItem fruitToolStripMenuItem = new ToolStripMenuItem("Fruit", null, null, "Fruit");

And then add it to your toolstrip:


More information can be found here:


This post has been edited by TheKirk: 17 February 2013 - 11:43 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1