C#,如何从基于托盘的应用程序调用表单对象
我正在尝试从最初使用的托盘图标运行的程序加载表单类,
FileList frmFileList = new FileList();
而不是文件列表,我想使用自定义表单,但收到错误:
错误1 'System.Windows.Forms.Control.ControlCollection' 不包含以下定义 “Cast”且无扩展方法“Cast” 接受类型的第一个参数 'System.Windows.Forms.Control.ControlCollection' 可以找到(您是否缺少 using 指令或程序集 参考?)
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您好像忘记了源文件顶部的
using System.Linq;
。但由于你没有发布来源,我不能确定。发布导致错误消息的代码行以及同一文件中的using
指令会有所帮助。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 theusing
directives that are in that same file would help.你确定你没有尝试这样的事情吗?
如果是这样,请将左侧的 FileList 更改为 SomethingDifferent。
Are you sure you are not trying something like this?
If so, change the FileList on the left side to SomethingDifferent.