C
C
Cach2014-09-22 20:52:32
C++ / C#
Cach, 2014-09-22 20:52:32

How to bypass duplicate tray icon in C#?

Good evening. Faced such problem:
There are two forms:
1. Form1. Attached to it are trayIcon and trayIconMenu
2. Form2. The form from which I need to reach the trayIconMenu and change the text in one of the menu items (menuItem1).
I do the following in Form2:
Form f2 = new Form1();
As a result, I get two icons in the tray. Why is this happening - I understand. When Form1 is created, a trayIcon attached to it is automatically generated. How can this be bypassed?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cach, 2014-09-22
@Cach

@aush Thanks for the help. I did it like this:
Program.cs:

public static Form1 MainForm1;

....

MainForm1 = new Form1();

Application.Run(MainForm1);

And in the form I need: I do
n’t know how true and correct it is, it works

A
aush, 2014-09-22
@aush

What exactly is your question? How to get a link to the first from the second form? You can pass the dependency on creation, you can through Application.OpenForms["Form1Name"]. Be more specific about your problem and show your code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question