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

2019-03-06 17:44发布

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?

2条回答
干净又极端
2楼-- · 2019-03-06 17:56

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.

查看更多
Lonely孤独者°
3楼-- · 2019-03-06 17:57

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.

查看更多
登录 后发表回答