How do I change font size on the DataGridView?
Use the Font-property on the gridview. See MSDN for details and samples:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.font.aspx
private void UpdateFont()
{
//Change cell font
foreach(DataGridViewColumn c in dgAssets.Columns)
{
c.DefaultCellStyle.Font = new Font("Arial", 8.5F, GraphicsUnit.Pixel);
}
}
In winform datagrid, right click to view its properties. It has a property called DefaultCellStyle. Click the ellipsis on DefaultCellStyle, then it will present Cell Style Builder window which has the option to change the font size.
Its easy.
The straight forward approach:
this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 15);
Go to designer.cs file of the form in which you have the grid view and comment the following line: - //this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
if you are using vs 2008 or .net framework 3.5 as it will be by default applied to alternating rows.
I too experienced same problem in the DataGridView but figured out that the DefaultCell style was inheriting the font of the groupbox (Datagrid is placed in groupbox). So changing the font of the groupbox changed the DefaultCellStyle too.
Regards