I've got a program in which I'm using a notifyicon only.
Most of it is drawn at design time, but i have one dropdown that comes from run time.
I can get this to draw the dropdown items and populate with directories and files with a Dropdown_opening event.
The problem is that I'm not able to get it to launch a process (in the form of a window when clicked on a directory or running a program for a file).
Here's a snippet of code that I'm using:
private void myStuffToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"E:\My Stuff");
foreach(DirectoryInfo name in dir.GetDirectories())
{
//add directories found in folder
myStuffToolStripMenuItem.DropDownItems.Add(name.Name);
}
FileInfo fil = new FileInfo(@"E:\My Stuff");
foreach(FileInfo name in fil.Directory.GetFiles())
{
//add files found as well
myStuffToolStripMenuItem.DropDownItems.Add(name.Name);
}
}
Thank you for any help you can give.
I'm new to programming and learning on my own (with little help from the web/other users), so please be patient.
Loading
Sam HobbsPosted Feb 12, 2010, 11:33 AM
Sam HobbsPosted Feb 11, 2010, 4:55 PM
There is a sample in the ToolStripDropDownItem Class documentation; look at that. I don't totally understand how it all works, but I hope you can figure it out. If you have more questions then ask about details. I especially do not understand what the ToolStripDropDownItem.DropDown Property is supposed to be.
ChrisPosted Feb 11, 2010, 9:56 AM
When I put my mouse over one item, it will run the code above when it opens.
That populates another set of menu items that are read from a directory.
I'm asking how I would be able to get a mouse click event to work on any one of those items that are populated at run time.
How do I get them to open the window for a directory or run a file that is populated at run time.
I know I need to raise a mouse click event, but I don't know how to go about doing that when they're drawn at run time.
Sam HobbsPosted Feb 10, 2010, 11:02 PM