How to loop through System.Windows.Forms.Shortcut Enumeration

Hi, I have to loop through the System.Windows.Forms.Shortcut Enumeration for set up automatically (reading from a database) the MenuItem shortcut.
The following method will return a shortcut:

private System.Windows.Forms.Shortcut GetMenuShortCut(string strMenuID)
        {
            System.Windows.Forms.Shortcut shrcutSalida = new Shortcut();

            foreach(System.Windows.Forms.Shortcut temp in )
            {
                if (temp.ToString() == dsMenu.Tables[0].Select("PKMENU='" +
                    strMenuID + "'")[0][9].ToString())
                {
                    shrcutSalida = temp;
                    break;
                }
            }

            return shrcutSalida;
        }

But i can’t make work "foreach" statement, someone has any idea

Thanks a lot,



Answer this question

How to loop through System.Windows.Forms.Shortcut Enumeration

  • Hallur_d

    Would this fit your scenario



    foreach (System.Windows.Forms.Shortcut temp in System.Enum.GetValues(typeof(System.Windows.Forms.Shortcut)))
    {
       ...
    }

     


    Best regards,
    Johan Stenberg



  • Balmer



    foreach (Shortcut temp in Enum.GetValues(typeof(Shortcut)))
    {
      ...
    }

     



    By the way, you could speed up that loop by pulling out the whole Table Select.

  • How to loop through System.Windows.Forms.Shortcut Enumeration