使用以下代码......

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 设置为什么,它都只会显示一个小的下拉列表(高度不会改变)。

任何想法为什么会发生这种情况?

最佳答案

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

关于c# - 不采用下拉大小设置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10356553/

10-15 11:05