I have a DataGridView for which I have disabled all resizing successfully. 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
:
If you set it to DisableResizing
, the height of headers can be controlled by ColumnHeadersHeight
.
If you set it to AutoSize
, the height of headers will be set based on the font and width of headers.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.