Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 decade ago

How can I loop through menuStrip in C# 2005?

All I want to do is loop through all the main menu items and its submenuitems in a menuStrip control in order to get their name and change enable property.

C# 2005 code pls.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    I hope this code will help you?????

    int userId = Classes.LogOnInfo.userId;

    My.Classes.Userights usr = new My.Classes.Userights();

    DataTable dt = usr.GetUserRights("spSelectUserRights", userId);

    foreach (DataRow row in dt.Rows)

    {

    for(int a = 0; a<=mnuMainStrip.Items.Count-1; a++)

    {

    if ((mnuMainStrip.Items[a].Name.ToString() == row["menuName"].ToString()) && ((row["flag"].ToString() == "True")))

    {

    mnuMainStrip.Items[a].Visible = true;

    }

    }

    }

Still have questions? Get your answers by asking now.