从另一个类调用 NotifyIcon.ShowBalloonTip()
我正在用 C# 开发 Windows 窗体应用程序。我有一个名为 MainWindow 的主窗体和一个名为 notifyIcon 的 NotifyIcon 对象,该对象属于 MainWindow 类。
我使用其他类的notifyIcon的最佳方法是什么?
我知道,如果没有实例,我只能访问类的公共静态成员,但是如果我将 notificationIcon 设置为公共静态,它就会停止在 MainWindow 上工作。
有什么想法吗?
I'm developing a Windows Form application in C#. I have a main form called MainWindow and a NotifyIcon object called notifyIcon that belongs to the MainWindow class.
What is the best way for me to use notifyIcon from other classes?
I know that, without an instance, I can only access public static members of the class, but if I set the notifyIcon as public static, it stops working on MainWindow.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它是同一应用程序,您可以使用它
来检索打开的表单。
该属性返回一个
FormCollection
,您可以从那里获取表单实例。 更多信息。如果不是同一个程序集
If it's the same application you can use
to retrieve opened forms.
This property returns a
FormCollection
, you can get the form instance from there. More info here.If it's not the same assembly see this.
您可以在表单上公开公共方法。该方法内部可以调用notifyicon上的方法
You can expose a public method on the form. This method can internally call the methods on notifyicon