问题
How can I change the row height of a DataGridView?
i set the value for the property but height doesnt changed,anyother property has to be checked before set this one
回答1:
You need to set the Height
property of the RowTemplate:
var dgv = new DataGridView();
dgv.RowTemplate.Height = 30;
回答2:
You can set the row height by code
dataGridView.RowTemplate.Height = 35;
or by property panel
回答3:
Try
datagridview.RowTemplate.MinimumHeight = 25;//25 is height.
I did that and it worked fine!
回答4:
you can do that on RowAdded Event :
_data_grid_view.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this._data_grid_view_RowsAdded);
private void _data_grid_view_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
_data_grid_view.Rows[e.RowIndex].Height = 42;
}
when a row add to the dataGridView it just change it height to 42.
回答5:
You also need to change the resizable property to true
dataGridView1.RowTemplate.Resizable = DataGridViewTriState.True;
dataGridView1.RowTemplate.Height = 50;
回答6:
You need to :
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
Then :
dataGridView1.ColumnHeadersHeight = 60;
回答7:
You can change the row height of the Datagridview in the
.cs [Design]
.
Then click the datagridview Properties
.
Look for RowTemplate
and expand it,
then type the value in the Height
.
回答8:
What you have to do is to set the MinimumHeight property of the row. Not only the Height property. That's the key. Put the code bellow in the CellPainting event of the datagridview
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
foreach(DataGridViewRow x in dataGridView1.Rows)
{
x.MinimumHeight = 50;
}
}
来源:https://stackoverflow.com/questions/3370236/changing-the-row-height-of-a-datagridview