0

I made my program with Visual Studio 2012, using Winforms, and the default DataGridView component.

It's possible change the zoom aspect of the grid?

In my particular case I need to view the grid a bit bigger, 120% or so.

I'd prefer do this at runtime, like Excel, but hardcoded is also OK.

4

1 回答 1

2

您可以使用以下方法Scale

dataGridView1.Scale(new SizeF(1.2f, 1.2f));

看起来你想要某种缩放,我想我们只需要放大FontDataGridView

public void ZoomGrid(float f){
   dataGridView1.Scale(new SizeF(f,f));
   dataGridView1.Font = new Font(dataGridView1.Font.FontFamily, 
                                 dataGridView1.Font.Size * f, dataGridView1.Font.Style);
   dataGridView1.RowTemplate.Height = (int)( dataGridView1.RowTemplate.Height * f);
   foreach (DataGridViewColumn col in dataGridView1.Columns) 
         col.Width = (int)(col.Width * f);
}
//
ZoomGrid(1.5f);
于 2013-08-22T16:24:38.920 回答