# C1.Win.TouchToolKit.DataGridViewZoomPolicy

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_Win_TouchToolKit_DataGridViewZoomPolicy" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy" class="text-break">DataGridViewZoomPolicy Class
</h1>
  <div class="markdown level0 summary"><p>Represents a zoom policy for <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.forms.datagridview">DataGridView</a> type control.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><a class="xref" href="C1.Win.TouchToolKit.ZoomPolicy.html">ZoomPolicy</a></div>
    <div class="level2"><span class="xref">DataGridViewZoomPolicy</span></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.Win.TouchToolKit.html">C1.Win.TouchToolKit</a></h6>
  <h6><strong>Assembly</strong>: C1.Win.TouchToolKit.4.8.dll</h6>
  <h5 id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class DataGridViewZoomPolicy : ZoomPolicy</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class DataGridViewZoomPolicy
    Inherits ZoomPolicy</code></pre>
  </div>
  <h5 id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><p>
This zoom policy will try to zoom all fonts and row height, column width.
</p>
<p>
If a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.forms.datagridview">DataGridView</a> has many rows or columns, change all cell's font，row's height or column's width
many bring performance problem. Change this property value to <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a> can solve the performance problem. 
</p>
</div>
  <h5 id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_examples"><strong>Examples</strong></h5>
  <p>
  The following code example shows how to use <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.html">DataGridViewZoomPolicy</a> class. 
</p>
<p>
  You can copy the code to a exsit Windows Forms appliction. And set the form in the sample code as start form. 
</p>
<p>
  If you find a licenses error when run this code. Try to drag a <a class="xref" href="C1.Win.TouchToolKit.C1Zoom.html">C1Zoom</a> component to a 
  any Form from tool box can generate the licenses information to this project.
</p>
<pre><code class="lang-csharp">public class DataGridViewZoomPolicyDemo : Form
{
	private DataGridView _dataGridView;
	private CheckBox _enableCheckBox;
	private CheckBox _fontCheckBox;
	private CheckBox _columnWidthCheckBox;
	private CheckBox _rowHeightCheckBox;
	private TextBox _targetTypeTextBox;
	private ListBox _defaultZoomPolicyListBox;
	private GcZoom _gcZoom1 = new GcZoom();
	private DataGridViewZoomPolicy _zoomPolicy = new DataGridViewZoomPolicy();

	public DataGridViewZoomPolicyDemo()
	{
		InitializeComponent();

		// DataGridView control should to change default font
		_dataGridView.ColumnHeadersDefaultCellStyle.Font = new Font(this.Font.FontFamily, this.Font.Size);
		_dataGridView.RowsDefaultCellStyle.Font = new Font(this.Font.FontFamily, this.Font.Size);

		_gcZoom1.Target = this;

		// Set DataGridView's ZoomPolicy object
		_gcZoom1.ZoomPolicies.Add(_zoomPolicy);

		GetTargetType();
		GetDefaultZoomPolicy();

		_enableCheckBox.CheckedChanged += _enableCheckBox_CheckedChanged;
		_fontCheckBox.CheckedChanged += _fontCheckBox_CheckedChanged;
		_columnWidthCheckBox.CheckedChanged += _columnWidthCheckBox_CheckedChanged;
		_rowHeightCheckBox.CheckedChanged += _rowHeightCheckBox_CheckedChanged;
	}

	void GetTargetType()
	{
		_targetTypeTextBox.Text = _zoomPolicy.TargetType.Name;
	}

	void GetDefaultZoomPolicy()
	{
		// Get GcZoom component build in zoompolicy of all
		foreach (ZoomPolicy item in _gcZoom1.DefaultZoomPolicies)
		{
			_defaultZoomPolicyListBox.Items.Add(item.ToString());
		}
	}

	void _enableCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_zoomPolicy.Enabled = _enableCheckBox.Checked;

		_fontCheckBox.Enabled = _enableCheckBox.Checked;
		_columnWidthCheckBox.Enabled = _enableCheckBox.Checked;
		_rowHeightCheckBox.Enabled = _enableCheckBox.Checked;
	}

	void _fontCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_zoomPolicy.ZoomCellStyleFont = _fontCheckBox.Checked;
	}

	void _columnWidthCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_zoomPolicy.ZoomColumnWidth = _columnWidthCheckBox.Checked;
	}

	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);

		_enableCheckBox = new CheckBox();
		_enableCheckBox.Text = "Enabled";
		_enableCheckBox.Size = new Size(120, 20);
		_enableCheckBox.Location = new Point(450, 20);
		_enableCheckBox.Checked = true;

		_fontCheckBox = new CheckBox();
		_fontCheckBox.Text = "ZoomCellStyleFont";
		_fontCheckBox.Size = new Size(120, 20);
		_fontCheckBox.Location = new Point(450, 50);
		_fontCheckBox.Checked = true;

		_columnWidthCheckBox = new CheckBox();
		_columnWidthCheckBox.Text = "ZoomColumnWidth";
		_columnWidthCheckBox.Size = new Size(120, 20);
		_columnWidthCheckBox.Location = new Point(450, 80);
		_columnWidthCheckBox.Checked = true;

		_rowHeightCheckBox = new CheckBox();
		_rowHeightCheckBox.Text = "ZoomRowHeight";
		_rowHeightCheckBox.Size = new Size(120, 20);
		_rowHeightCheckBox.Location = new Point(450, 110);
		_rowHeightCheckBox.Checked = true;

		_targetTypeTextBox = new TextBox();
		_targetTypeTextBox.ReadOnly = true;
		_targetTypeTextBox.Size = new Size(120, 20);
		_targetTypeTextBox.Location = new Point(450, 140);

		_defaultZoomPolicyListBox = new ListBox();
		_defaultZoomPolicyListBox.Size = new Size(300, 200);
		_defaultZoomPolicyListBox.Location = new Point(450, 170);

		this.Controls.Add(_dataGridView);
		this.Controls.Add(_enableCheckBox);
		this.Controls.Add(_fontCheckBox);
		this.Controls.Add(_columnWidthCheckBox);
		this.Controls.Add(_rowHeightCheckBox);
		this.Controls.Add(_targetTypeTextBox);
		this.Controls.Add(_defaultZoomPolicyListBox);
		this.Size = new Size(800, 600);
	}
}</code></pre>
<pre><code class="lang-csharp">Public Class DataGridViewZoomPolicyDemo
	Inherits Form
	Private _dataGridView As DataGridView
	Private _enableCheckBox As CheckBox
	Private _fontCheckBox As CheckBox
	Private _columnWidthCheckBox As CheckBox
	Private _rowHeightCheckBox As CheckBox
	Private _targetTypeTextBox As TextBox
	Private _defaultZoomPolicyListBox As ListBox
	Private _gcZoom1 As New GcZoom()
	Private _zoomPolicy As New DataGridViewZoomPolicy()

	Public Sub New()
		InitializeComponent()

		' DataGridView control should to change default font
		_dataGridView.ColumnHeadersDefaultCellStyle.Font = New Font(Me.Font.FontFamily, Me.Font.Size)
		_dataGridView.RowsDefaultCellStyle.Font = New Font(Me.Font.FontFamily, Me.Font.Size)

		_gcZoom1.Target = Me

		' Set DataGridView's ZoomPolicy object
		_gcZoom1.ZoomPolicies.Add(_zoomPolicy)

		GetTargetType()
		GetDefaultZoomPolicy()

		AddHandler _enableCheckBox.CheckedChanged, AddressOf _enableCheckBox_CheckedChanged
		AddHandler _fontCheckBox.CheckedChanged, AddressOf _fontCheckBox_CheckedChanged
		AddHandler _columnWidthCheckBox.CheckedChanged, AddressOf _columnWidthCheckBox_CheckedChanged
		AddHandler _rowHeightCheckBox.CheckedChanged, AddressOf _rowHeightCheckBox_CheckedChanged
	End Sub

	Private Sub GetTargetType()
		_targetTypeTextBox.Text = _zoomPolicy.TargetType.Name
	End Sub

	Private Sub GetDefaultZoomPolicy()
		' Get GcZoom component build in zoompolicy of all
		For Each item As ZoomPolicy In _gcZoom1.DefaultZoomPolicies
			_defaultZoomPolicyListBox.Items.Add(item.ToString())
		Next
	End Sub

	Private Sub _enableCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_zoomPolicy.Enabled = _enableCheckBox.Checked

		_fontCheckBox.Enabled = _enableCheckBox.Checked
		_columnWidthCheckBox.Enabled = _enableCheckBox.Checked
		_rowHeightCheckBox.Enabled = _enableCheckBox.Checked
	End Sub

	Private Sub _fontCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_zoomPolicy.ZoomCellStyleFont = _fontCheckBox.Checked
	End Sub

	Private Sub _columnWidthCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_zoomPolicy.ZoomColumnWidth = _columnWidthCheckBox.Checked
	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)

		_enableCheckBox = New CheckBox()
		_enableCheckBox.Text = "Enabled"
		_enableCheckBox.Size = New Size(120, 20)
		_enableCheckBox.Location = New Point(450, 20)
		_enableCheckBox.Checked = True

		_fontCheckBox = New CheckBox()
		_fontCheckBox.Text = "ZoomCellStyleFont"
		_fontCheckBox.Size = New Size(120, 20)
		_fontCheckBox.Location = New Point(450, 50)
		_fontCheckBox.Checked = True

		_columnWidthCheckBox = New CheckBox()
		_columnWidthCheckBox.Text = "ZoomColumnWidth"
		_columnWidthCheckBox.Size = New Size(120, 20)
		_columnWidthCheckBox.Location = New Point(450, 80)
		_columnWidthCheckBox.Checked = True

		_rowHeightCheckBox = New CheckBox()
		_rowHeightCheckBox.Text = "ZoomRowHeight"
		_rowHeightCheckBox.Size = New Size(120, 20)
		_rowHeightCheckBox.Location = New Point(450, 110)
		_rowHeightCheckBox.Checked = True

		_targetTypeTextBox = New TextBox()
		_targetTypeTextBox.[ReadOnly] = True
		_targetTypeTextBox.Size = New Size(120, 20)
		_targetTypeTextBox.Location = New Point(450, 140)

		_defaultZoomPolicyListBox = New ListBox()
		_defaultZoomPolicyListBox.Size = New Size(300, 200)
		_defaultZoomPolicyListBox.Location = New Point(450, 170)

		Me.Controls.Add(_dataGridView)
		Me.Controls.Add(_enableCheckBox)
		Me.Controls.Add(_fontCheckBox)
		Me.Controls.Add(_columnWidthCheckBox)
		Me.Controls.Add(_rowHeightCheckBox)
		Me.Controls.Add(_targetTypeTextBox)
		Me.Controls.Add(_defaultZoomPolicyListBox)
		Me.Size = New Size(800, 600)
	End Sub
End Class</code></pre>

  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy__ctor" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.#ctor">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.-ctor.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy__ctor">DataGridViewZoomPolicy()</a>
        </td>
        <td class="markdown level1 summary"></td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_TargetType" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.TargetType">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.TargetType.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_TargetType">TargetType</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the type indicates which control type can use this policy.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomCellStyleFont" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomCellStyleFont">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomCellStyleFont.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomCellStyleFont">ZoomCellStyleFont</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets a value indicating whether zoom cell style's font.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomColumnWidth" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomColumnWidth">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomColumnWidth.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomColumnWidth">ZoomColumnWidth</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets a value indicating whether resize column's width.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomRowHeight" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomRowHeight">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomRowHeight.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomRowHeight">ZoomRowHeight</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets a value indicating whether resize row's height.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomBounds_System_Windows_Forms_Control_C1_Win_TouchToolKit_ZoomBoundsInfo_" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomBounds(System.Windows.Forms.Control,C1.Win.TouchToolKit.ZoomBoundsInfo)">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomBounds.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomBounds_System_Windows_Forms_Control_C1_Win_TouchToolKit_ZoomBoundsInfo_">ZoomBounds(Control, ZoomBoundsInfo)</a>
        </td>
        <td class="markdown level1 summary"><p>Zoom the control bounds.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomFont_System_Windows_Forms_Control_C1_Win_TouchToolKit_ZoomFontInfo_" data-uid="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomFont(System.Windows.Forms.Control,C1.Win.TouchToolKit.ZoomFontInfo)">
          <a class="xref" href="C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomFont.html#C1_Win_TouchToolKit_DataGridViewZoomPolicy_ZoomFont_System_Windows_Forms_Control_C1_Win_TouchToolKit_ZoomFontInfo_">ZoomFont(Control, ZoomFontInfo)</a>
        </td>
        <td class="markdown level1 summary"><p>Zoom the control font.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="seealso">See Also</h3>
  <div class="seealso">
      <div><a class="xref" href="C1.Win.TouchToolKit.ZoomPolicy.html">ZoomPolicy</a></div>
  </div>

</div>
