winforms - Get source of event in C# Windows Forms -
i have list of string
want create menu of toolstripitem
(neither list size nor content know @ debug) , want each item execute same event, go through list code:
foreach (string in items) { toolstripitem item = (toolstripitem)toolstripmenuitem1.dropdownitems.add(i); item.click += new eventhandler(item_click); }
the problem in item_click
method need know of above items triggered event. if in wpf, have used routedeventargs
, .source
proprety since in regular windows forms app, i'm not quite sure how it. there simple way it? thank you.
use sender
parameter in click event
var item = sender toolstripitem; if(item != null) { ... }
Comments
Post a Comment