C# 从控件转换为函数<;控制>;对于选项卡式视图-Devexpress Windows窗体
我正在为Windows窗体应用程序使用Devexpress。 所以我想替换这个片段:C# 从控件转换为函数<;控制>;对于选项卡式视图-Devexpress Windows窗体,c#,windows,forms,devexpress,C#,Windows,Forms,Devexpress,我正在为Windows窗体应用程序使用Devexpress。 所以我想替换这个片段: tabbedView.AddDocument(userControl); tabbedView.ActivateDocument(userControl); tabbedView.AddOrActivateDocument(doc => doc.Caption == e.Element.Name, userControl); 使用此代码段: tabbedView.AddDocument(userCon
tabbedView.AddDocument(userControl);
tabbedView.ActivateDocument(userControl);
tabbedView.AddOrActivateDocument(doc => doc.Caption == e.Element.Name, userControl);
使用此代码段:
tabbedView.AddDocument(userControl);
tabbedView.ActivateDocument(userControl);
tabbedView.AddOrActivateDocument(doc => doc.Caption == e.Element.Name, userControl);
这里的问题是,此方法请求Func
而不是控件
我找到了Func
文档和规范,但找不到如何将对象
转换为其Func
我感谢你的帮助。谢谢。Func
意味着它不接受任何参数,而是返回一个控件,比如
public Func<Control> getControl = () => new Control();
Func
意味着它不接受任何参数并返回一个控件
,类似于public Func getControl=()=>new Control()代码>可以通过传递lambda表达式来修复此问题。试试这个tabbedView.AddOrActivateDocument(doc=>doc.Caption==e.Element.Name,()=>userControl)代码>谢谢你,先生!这解决了我的问题,但我还不理解这个概念。这就是我所做的,解决了我的问题。非常感谢。这只是一个建议。在发布此类问题时,攻击文档链接总是很好的。我能够通过实际阅读文档找出解决方案:)