Querry模式的实现 [英] implementation of querry pattern

查看:62
本文介绍了Querry模式的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,其中有错误
找不到Querry模式的实现


here is my code in which there is an error
could not find the implementation of querry pattern


var menuItem = (from item in menuStrip1.items
                where item is ToolStripMenuItem && item.Text == s1
                select item).FirstOrDefault();
if (menuItem != null)
{
    menuItem.Visible = true;
}



[edit]已添加代码块,忽略HTML ..."选项已禁用-OriginalGriff [/edit]



[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]

推荐答案

ToolStripItemCollection不支持WHERE查询:尝试这样做而是使用foreach循环.
ToolStripItemCollection does not support the WHERE query: try doing it with a foreach loop instead.


尝试一下,

Try this,

public void SetVisibility(string menuItemText)
{
    foreach (ToolStripMenuItem menuItem in menuStrip1.Items)
    {
        if (menuItem.Text == menuItemText){
            menuItem.Visible = true;
            break;  
        }      
    }
}



:)



:)


这篇关于Querry模式的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆