#1 -- The ContextMenu
Expand|Select|Wrap|Line Numbers
- this.Tray_Icon_Context_Menu.MenuItems.Add("Open Tray", new System.EventHandler(Open_Tray));
- this.Tray_Icon_Context_Menu.MenuItems.Add("Close Tray", new System.EventHandler(Close_Tray));
- this.Tray_Icon_Context_Menu.MenuItems.Add("Set Default (" + Properties.Settings.Default.Disc_Drive + ")");
- this.Tray_Icon_Context_Menu.MenuItems.Add("Close Application", new System.EventHandler(Close_Application));
Expand|Select|Wrap|Line Numbers
- private bool Update_Context_Menu(System.Collections.Generic.Lis t<string> Active_Disc_Drives)
- {
- this.Disc_Drive_Memory.Clear();
- this.Tray_Icon_Context_Menu.MenuItems[2].MenuItems.Clear();
- if (!Active_Disc_Drives.Contains(Properties.Settings. Default.Disc_Drive))
- {
- Properties.Settings.Default.Disc_Drive = "";
- Properties.Settings.Default.Save();
- if (Properties.Settings.Default.Disc_Drive == "") Tray_Icon_Context_Menu.MenuItems[2].Text = ("Set Default (N/A)");
- }
- foreach (string Active_Disc_Drive in Active_Disc_Drives)
- {
- Disc_Drive_Memory.Add(Active_Disc_Drive);
- System.Windows.Forms.MenuItem Item = new System.Windows.Forms.MenuItem(Active_Disc_Drive, new System.EventHandler(Set_Default_Drive));
- Tray_Icon_Context_Menu.MenuItems[2].MenuItems.Add(Item);
- if (Tray_Icon_Context_Menu.MenuItems[2].MenuItems[Tray_Icon_Context_Menu.MenuItems[2].MenuItems.IndexOf(Item)].Text == Properties.Settings.Default.Drive) Tray_Icon_Context_Menu.MenuItems[2].MenuItems[Tray_Icon_Context_Menu.MenuItems[2].MenuItems.IndexOf(Item)].Checked = true;
- else Tray_Icon_Context_Menu.MenuItems[2].MenuItems[Tray_Icon_Context_Menu.MenuItems[2].MenuItems.IndexOf(Item)].Checked = false;
- }
- if (Tray_Icon_Context_Menu.MenuItems[2].MenuItems.Count == 0) Tray_Icon_Context_Menu.MenuItems[2].Enabled = false;
- else Tray_Icon_Context_Menu.MenuItems[2].Enabled = true;
- return true;
- }
How do I get the text of the selected MenuItem (Disc Drive) on the Click Event? It'd be easy if the drive amount wouldn't change, I'd just need to make an event for each drive, but the thing is the amount can change.
So what I need is a way for each MenuItem to create its own Click Event, or a way to send the selected items text to a event like the following.
Expand|Select|Wrap|Line Numbers
- private void Set_Default_Drive()
- {
- Properties.Settings.Default.Disc_Drive = /* Insert Drive Name Here */;
- Properties.Settings.Default.Save();
- Tray_Icon_Context_Menu.MenuItems[2].Text = "Set Default (" + Properties.Settings.Default.Drive + ")";
- }
If you think I may have forgotten to add somethings to explain something, let me know.