List Info

Thread: C-Sharp (C#) Group: Dynamic menu items ... problem




C-Sharp (C#) Group: Dynamic menu items ... problem
user name
2006-01-29 14:02:21
Hello,

I have developed a small Pocket PC application and populated a menu option with items from an XML file. I need to handle the click event for the items dynamically.
The sequence for add the item to the menu is the following:

------------------------------------------------------------------------------------------------------------------

      ;      MenuItem[] miLangs = new MenuItem[ds.Tables[0].Rows.Count];

 &nbsp;   ; &nbsp; &nbsp; &nbsp; for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  {
 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; Array a = ds.Tables[0].Rows[i].ItemArray;
  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; miLangs[i] = new MenuItem();
 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; miLangs[i].Text = a.GetValue(0).ToString();
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  miLangs[i].Click += new System.EventHandler(this.switchLanguage);&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; 
 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; miLanguage.MenuItems.Add(miLangs[i]);
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  }

------------------------------------------------------------------------------------------------------------------

The function to handle the click event is:

------------------------------------------------------------------------------------------------------------------

private void switchLanguage(object sender, EventArgs e)
   ; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp;   ; &nbsp;
 &nbsp; &nbsp; &nbsp;   ; &nbsp; // I need the code to make the difference between the different items  &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp;  }

------------------------------------------------------------------------------------------------------------------

What I need is the code to make the difference betwween the items. I need something to get the text of the item clicked or something to see the difference. I tryed something but wasn't able to do what I need :-(

Thanks in advance!

AndreiC

--
Croitoriu Andrei
andrei.croitoriugmail.com">andrei.croitoriugmail.com
http://www.stud.usv.ro/~acroitoriu
"No complexity beyond what is necessary&quot;
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )