[]
Gets or sets a value indicating whether resize row's height.
public bool ZoomRowHeight { get; set; }
Type | Description |
---|---|
bool |
If you need to solve performance problem. see DataGridViewZoomPolicy.
The following code example shows how to use this property.
This code example is part of a larger example provided for the DataGridViewZoomPolicy class.
public class DataGridViewZoomPolicyDemo : Form
{
private DataGridView _dataGridView;
private CheckBox _rowHeightCheckBox;
private GcZoom _gcZoom1 = new GcZoom();
private DataGridViewZoomPolicy _zoomPolicy = new DataGridViewZoomPolicy();
public DataGridViewZoomPolicyDemo()
{
InitializeComponent();
_gcZoom1.Target = this;
// Set DataGridView's ZoomPolicy object
_gcZoom1.ZoomPolicies.Add(_zoomPolicy);
_rowHeightCheckBox.CheckedChanged += _rowHeightCheckBox_CheckedChanged;
}
void _rowHeightCheckBox_CheckedChanged(object sender, EventArgs e)
{
_gcZoom1.ZoomFactor = 1f;
_zoomPolicy.ZoomRowHeight = _rowHeightCheckBox.Checked;
}
private void InitializeComponent()
{
_dataGridView = new DataGridView();
_dataGridView.Location = new Point(20, 20);
_dataGridView.Size = new Size(400, 500);
DataGridViewColumn column1 = new DataGridViewColumn();
column1.CellTemplate = new DataGridViewTextBoxCell();
column1.HeaderText = "Column 1";
_dataGridView.Columns.Add(column1);
DataGridViewColumn column2 = new DataGridViewColumn();
column2.CellTemplate = new DataGridViewTextBoxCell();
column2.HeaderText = "Column 2";
_dataGridView.Columns.Add(column2);
DataGridViewColumn column3 = new DataGridViewColumn();
column3.CellTemplate = new DataGridViewTextBoxCell();
column3.HeaderText = "Column 3";
_dataGridView.Columns.Add(column3);
_rowHeightCheckBox = new CheckBox();
_rowHeightCheckBox.Text = "ZoomRowHeight";
_rowHeightCheckBox.Size = new Size(120, 20);
_rowHeightCheckBox.Location = new Point(450, 110);
_rowHeightCheckBox.Checked = true;
this.Controls.Add(_dataGridView);
this.Controls.Add(_rowHeightCheckBox);
}
}
Public Class DataGridViewZoomPolicyDemo
Inherits Form
Private _dataGridView As DataGridView
Private _rowHeightCheckBox As CheckBox
Private _gcZoom1 As New GcZoom()
Private _zoomPolicy As New DataGridViewZoomPolicy()
Public Sub New()
InitializeComponent()
_gcZoom1.Target = Me
' Set DataGridView's ZoomPolicy object
_gcZoom1.ZoomPolicies.Add(_zoomPolicy)
AddHandler _rowHeightCheckBox.CheckedChanged, AddressOf _rowHeightCheckBox_CheckedChanged
End Sub
Private Sub _rowHeightCheckBox_CheckedChanged(sender As Object, e As EventArgs)
_gcZoom1.ZoomFactor = 1.0F
_zoomPolicy.ZoomRowHeight = _rowHeightCheckBox.Checked
End Sub
Private Sub InitializeComponent()
_dataGridView = New DataGridView()
_dataGridView.Location = New Point(20, 20)
_dataGridView.Size = New Size(400, 500)
Dim column1 As New DataGridViewColumn()
column1.CellTemplate = New DataGridViewTextBoxCell()
column1.HeaderText = "Column 1"
_dataGridView.Columns.Add(column1)
Dim column2 As New DataGridViewColumn()
column2.CellTemplate = New DataGridViewTextBoxCell()
column2.HeaderText = "Column 2"
_dataGridView.Columns.Add(column2)
Dim column3 As New DataGridViewColumn()
column3.CellTemplate = New DataGridViewTextBoxCell()
column3.HeaderText = "Column 3"
_dataGridView.Columns.Add(column3)
_rowHeightCheckBox = New CheckBox()
_rowHeightCheckBox.Text = "ZoomRowHeight"
_rowHeightCheckBox.Size = New Size(120, 20)
_rowHeightCheckBox.Location = New Point(450, 110)
_rowHeightCheckBox.Checked = True
Me.Controls.Add(_dataGridView)
Me.Controls.Add(_rowHeightCheckBox)
End Sub
End Class