I have a form (Form1) on which there is NotifyIcon. I have another form (Form2) with which I would like to change the NotifyIcon icon. Whenever I use this code, I get an additional icon that appears in the system tray instead of changing the current icon:
Form1 (ico - name NotifyIcon):
public string DisplayIcon { set { ico.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Alerts.Icons." + value)); } }
Form2:
Form1 form1 = new Form1(); form1.DisplayIcon = "on.ico";
I suspect this is due to creating a new instance of Form1 on Form2, but I'm not sure how to access the "DisplayIcon" without doing this. Thanks.
UDPATE: I am a bit confused about writing a custom property in form 2, it would be something like:
public Form Form1 { set {value;} }
source share