How do I set the row height in DataGrid? I don't see any property anywhere to achieve that. I am using .NET 3.5 and it's a WinForms application written in C#.
EDITED
Here is the piece of code that assigns the datasouce, you can see that I set the prefered height before that
dgMyGrid.PreferredRowHeight = 64;
dgMyGrid.DataSource = samples;
If I remember well there is a property named PreferredRowHeight. Should be set before the databinding.
Steve's answer works:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dataGrid1.PreferredRowHeight = 64;
myTableAdapter.Fill(myDataSet.myTable);
}
}
Will produce a grid with rows at a height of 64. However, this doesn't work:
private void Form1_Load(object sender, EventArgs e)
{
myTableAdapter.Fill(myDataSet.myTable);
dataGrid1.PreferredRowHeight = 64; // has no effect because the grid is already drawn
}
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.