C#, how to call a form object from a tray based application

偶尔善良 提交于 2019-12-04 07:01:18

问题


I am trying to load a form class from a program running as a tray icon that originally used

FileList frmFileList = new FileList();

Now instead of a filelist I want to use a custom form but I get the error:

Error 1 'System.Windows.Forms.Control.ControlCollection' does not contain a definition for 'Cast' and no extension method 'Cast' accepting a first argument of type 'System.Windows.Forms.Control.ControlCollection' could be found (are you missing a using directive or an assembly reference?)

Any ideas?


回答1:


It sounds like you forgot using System.Linq; at the top of your source file. But since you didn't post the sources, I can't say for sure. Posting the line of code that causes the error message, and the using directives that are in that same file would help.




回答2:


Are you sure you are not trying something like this?

FileList frmFileList = new SomethingDifferent();

If so, change the FileList on the left side to SomethingDifferent.



来源:https://stackoverflow.com/questions/4568815/c-how-to-call-a-form-object-from-a-tray-based-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!