下拉尺寸设置没有采取

时间:2012-04-27 19:15:22

标签: c# .net winforms drop-down-menu

使用以下代码.....

ToolStripControlHost treeViewHost;
    ToolStripDropDown dropDown;
    public MyTreeViewCombo()
    {
        TreeView treeView = new TreeView();
        treeView.BorderStyle = BorderStyle.None;
        treeViewHost = new ToolStripControlHost(treeView);
        // create drop down and add it
        dropDown = new ToolStripDropDown();
        dropDown.Items.Add(treeViewHost);
    }
    public TreeView TreeView
    {
        get { return treeViewHost.Control as TreeView; }
    }
    private void ShowDropDown()
    {
        if (dropDown != null)
        {
            dropDown.Height = DropDownHeight;
            dropDown.Width = DropDownWidth;
            treeViewHost.Width = DropDownWidth;
            treeViewHost.Height = DropDownHeight;
            dropDown.Show(this, 0, this.Height);
        }
    }
    [...]

无论dropDownHeight设置为什么,它都只会显示一个小的下拉列表(高度不会改变)。

为什么会发生这种情况?

1 个答案:

答案 0 :(得分:3)

检查是否有其他财产阻止了它。也许AutoSize属性设置为true

相关问题