WinForms DataGridView font size

前端 未结 10 1838
半阙折子戏
半阙折子戏 2020-12-09 07:47

How do I change font size on the DataGridView?

相关标签:
10条回答
  • 2020-12-09 07:55

    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

    0 讨论(0)
  • 2020-12-09 07:57
        private void UpdateFont()
        {
            //Change cell font
            foreach(DataGridViewColumn c in dgAssets.Columns)
            {
                c.DefaultCellStyle.Font = new Font("Arial", 8.5F, GraphicsUnit.Pixel);
            }
        }
    
    0 讨论(0)
  • 2020-12-09 08:04

    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.

    0 讨论(0)
  • 2020-12-09 08:05

    The straight forward approach:

    this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 15);
    
    0 讨论(0)
  • 2020-12-09 08:07

    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.

    0 讨论(0)
  • 2020-12-09 08:10

    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

    0 讨论(0)
提交回复
热议问题