c# - WinForms - Baffled - How to Handle Certain Controls Dynamically - Properly -


I have a system.window.form class (my main category). It's my own custom object, it's my own custom object. I'm trying to loop through the rootmeni object and add a ToolStripMenuItem to every one in ContextMenuStrip (which I have named ContextMenu). The rootmen object contains a list of link names and URLs (both strings).

When the form loads my "Factory" class, I load the Rutimano object, which I then send in the processman method.

Code excerpt here:

  Private Zero Process Menu (Routen RM) {foreach (var lnk in rm.Links) {var tsmi = new toolstripMenuItem (lnk.Name, Null, new eventhandler (navigate); Tsmi.ToolTipText = lnk.Url; ContextMenu.Items.Add (tsmi); }} Navigate Private Zero (Object Sender, EventAgds E) {var tsmi = (ToolStripMenuItem) Sender; System.Diagnostics.Process.Start (tsmi.ToolTipText); }  

Do you see how to store lnk.Url in the tooltip text? In VB6 days all the controls had the "tag" property you used to be able to control the extra luggage in the control, which you will later need. I do not want to use tooltips for this, but what are my options? Store all URLs in a hash / dictionary as an important name? I do not always have unique names, so I would like to avoid this route. What is the proper way to handle it in .NET? Maybe I was missing some basic concept that never came to me.

toolstep menu is a tag property:

/ P>
  tsmi.Tag = lnk.Url;  

In fact, there are some Windows form controls in it.


Comments