如何将ToolStripMenuItem滚动到特定项目

时间:2018-02-08 15:15:47

标签: c#

我有一个带有垂直滚动条的大ToolStripMenuItem表。我想滚动到此表中的特定项目

{

    MenuStrip strip = new MenuStrip();

    ToolStripMenuItem fileItem = new ToolStripMenuItem("&File");

    // Create an array of ToolStripMenuItems
    ToolStripMenuItem[] col = new ToolStripMenuItem[20];

    // Populate the list with menus named "Menu 1" through "Menu 4"
    for (int i = 0; i < 20; i++)
    {
        col[i] = new ToolStripMenuItem("Menu " + (i + 1));

        // Make first item checked
        if (i == 0)
        {
            col[i].Checked = true;
        }
    }

    // Create menu item containing icon and a collection
    ToolStripMenuItem collectionMenu = new ToolStripMenuItem("Collection", Image.FromFile("c:\\Arrow.png"), col);

    fileItem.DropDownItems.Add(collectionMenu);
    collectionMenu.DropDown.AutoSize = false;
    collectionMenu.DropDown.Height = 100;


    strip.Items.Add(fileItem);

    this.Controls.Add(strip);

}

我需要打开下拉列表和menu15可见

enter image description here

0 个答案:

没有答案