Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 4-Aug-11 1:06am
v2

ToolStripItemCollection does not support the WHERE query: try doing it with a foreach loop instead.
 
Share this answer
 
Comments
kami124 4-Aug-11 7:15am    
how to use foreach with this code
Try this,

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


:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900