Click here to Skip to main content
15,901,205 members
Home / Discussions / C#
   

C#

 
GeneralRe: Search a treeView Pin
Anonymous15-Jul-05 11:15
Anonymous15-Jul-05 11:15 
GeneralRe: Search a treeView Pin
Joel Lucsy15-Jul-05 16:41
Joel Lucsy15-Jul-05 16:41 
GeneralNumber TextBox Pin
Kamrul Hasan15-Jul-05 8:22
Kamrul Hasan15-Jul-05 8:22 
GeneralRe: Number TextBox Pin
Judah Gabriel Himango15-Jul-05 9:40
sponsorJudah Gabriel Himango15-Jul-05 9:40 
GeneralRe: Number TextBox Pin
MoustafaS15-Jul-05 10:28
MoustafaS15-Jul-05 10:28 
GeneralRe: Number TextBox Pin
Alomgir Miah15-Jul-05 11:14
Alomgir Miah15-Jul-05 11:14 
GeneralMenu Items Question Pin
zaboboa15-Jul-05 7:47
zaboboa15-Jul-05 7:47 
GeneralRe: Menu Items Question Pin
Robert Rohde15-Jul-05 10:23
Robert Rohde15-Jul-05 10:23 
In those situations I prefer inheriting my own class from MenuItem e.g.:
private class MyMenuItem : MenuItem 
{
   private string _version;

   public MyMenuItem(string version) : base() 
   {
      _version = version;
      string[] splitStr = Convert.ToString(_version).Split('~');
      base.Text = "Version: "+splitStr[0]+" --- "+splitStr[1];
   }

   public string Version 
   {
      get { return _version; }
   }
}


Your code would then look like:
foreach (object i in versionsAnddates) {
SubMenu = new MyMenuItem (Convert.ToString(i));
this.projectsMenu.MenuItems.AddRange (new MenuItem[] {this.SubMenu});
this.projectsSubMenu.Click += new System.EventHandler(this.Version_Click);
}


and the event handler...
private void Version_Click(object sender, EventArgs e)
{
   MyMenuItem mmi = sender as MyMenuItem;
   if (mmi != null) 
   {
      Console.WriteLine(mmi.Version);
   }
}

GeneralRe: Menu Items Question Pin
zaboboa18-Jul-05 3:28
zaboboa18-Jul-05 3:28 
QuestionHow to XML Document to store settings? Pin
Cheng Zhong15-Jul-05 7:00
Cheng Zhong15-Jul-05 7:00 
AnswerRe: How to XML Document to store settings? Pin
DavidNohejl15-Jul-05 8:26
DavidNohejl15-Jul-05 8:26 
GeneralRe: How to XML Document to store settings? Pin
Cheng Zhong15-Jul-05 17:37
Cheng Zhong15-Jul-05 17:37 
AnswerRe: How to XML Document to store settings? Pin
Judah Gabriel Himango15-Jul-05 9:42
sponsorJudah Gabriel Himango15-Jul-05 9:42 
GeneralGraphics Class Pin
Amir Jalaly15-Jul-05 6:57
Amir Jalaly15-Jul-05 6:57 
GeneralRe: Graphics Class Pin
Dave Kreskowiak15-Jul-05 9:37
mveDave Kreskowiak15-Jul-05 9:37 
GeneralRe: Graphics Class Pin
Muhammad Gulzaib Khan16-Jul-05 9:03
Muhammad Gulzaib Khan16-Jul-05 9:03 
GeneralRe: Graphics Class Pin
Amir Jalaly16-Jul-05 20:56
Amir Jalaly16-Jul-05 20:56 
Generalcommunicate with other app from an app Pin
ppp00115-Jul-05 6:19
ppp00115-Jul-05 6:19 
GeneralRe: communicate with other app from an app Pin
Alexander Kent15-Jul-05 10:24
Alexander Kent15-Jul-05 10:24 
GeneralUpdating Windows components Pin
Heapster15-Jul-05 6:18
Heapster15-Jul-05 6:18 
GeneralRe: Updating Windows components Pin
Alexander Kent15-Jul-05 10:23
Alexander Kent15-Jul-05 10:23 
GeneralRe: Updating Windows components Pin
Heapster15-Jul-05 11:22
Heapster15-Jul-05 11:22 
GeneralPrinting Word Documents Pin
tartanmonkey15-Jul-05 4:56
tartanmonkey15-Jul-05 4:56 
GeneralRe: Printing Word Documents Pin
Dave Kreskowiak15-Jul-05 5:36
mveDave Kreskowiak15-Jul-05 5:36 
GeneralRe: Printing Word Documents Pin
tartanmonkey15-Jul-05 5:45
tartanmonkey15-Jul-05 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.