简体   繁体   English

DataGridView禁用标题的垂直调整大小

[英]DataGridView disable vertical resize of the header

I have a DataGridView for which I have disabled all resizing successfully. 我有一个DataGridView,已成功禁用所有大小调整。 Except the vertical resize of the column headers, as I can't find a way to do that.. What's the property to change? 除了列标题的垂直调整大小外,我无法找到一种方法来进行更改。要更改的属性是什么?

 class TransactionOverView : DataGridView {
        public TransactionOverView() {
            this.ClientSize = new Size(1008,720);
            this.AllowDrop = false;
            this.Columns.Add("nimetusColumn","Nimetus");
            this.Columns.Add("kogusColumn", "Kogus");
            this.Columns.Add("hindColumn", "Hind");
            this.Rows.Add("Toode 1","1","10.00 €");
            this.RowHeadersVisible = false;
            this.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.MultiSelect = false;
            this.ReadOnly = true;
            this.AllowUserToResizeRows = false;
            this.AllowUserToResizeColumns = false;
            this.AllowUserToAddRows = false;
            this.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;

            foreach (DataGridViewColumn column in this.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }

        }
}

You can prevent changing the height of column headers by setting ColumnHeadersHeightSizeMode to DisableResizing or AutoSize : 您可以通过将ColumnHeadersHeightSizeMode设置为DisableResizingAutoSize来防止更改列标题的高度:

  • If you set it to DisableResizing , the height of headers can be controlled by ColumnHeadersHeight . 如果将其设置为DisableResizing ,则标题的高度可以由ColumnHeadersHeight控制。

  • If you set it to AutoSize , the height of headers will be set based on the font and width of headers. 如果将其设置为AutoSize ,则会根据标题的字体和宽度来设置标题的高度。

ColumnHeadersHeightSizeMode

Gets or sets a value indicating whether the height of the column headers is adjustable and whether it can be adjusted by the user or is automatically adjusted to fit the contents of the headers. 获取或设置一个值,该值指示列标题的高度是可调整的,还是可以由用户调整还是自动调整以适合标题的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM