[]
        
(Showing Draft Content)

C1.Win.TouchToolKit.DataGridViewZoomPolicy.ZoomCellStyleFont

ZoomCellStyleFont Property

ZoomCellStyleFont

Gets or sets a value indicating whether zoom cell style's font.

Declaration
public bool ZoomCellStyleFont { get; set; }
Property Value
Type Description
bool

true if zoom cell style's font; otherwise, false. Default is true.

Remarks

If set this property to true, the DataGridView's AlternatingRowsDefaultCellStyle, AlternatingRowsDefaultCellStyle, ColumnHeadersDefaultCellStyle, DefaultCellStyle, RowHeadersDefaultCellStyle, RowsDefaultCellStyle properties' font property will be changed. And all row/column/cell's font will be changed.

If you need to solve performance problem. see DataGridViewZoomPolicy.

Examples

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

		_fontCheckBox.CheckedChanged += _fontCheckBox_CheckedChanged;
	}

	void _fontCheckBox_CheckedChanged(object sender, EventArgs e)
	{
		_gcZoom1.ZoomFactor = 1f;
		_zoomPolicy.ZoomCellStyleFont = _fontCheckBox.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);

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

		this.Controls.Add(_dataGridView);
		this.Controls.Add(_fontCheckBox);
	}
}
Public Class DataGridViewZoomPolicyDemo
	Inherits Form
	Private _dataGridView As DataGridView
	Private _fontCheckBox As CheckBox
	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)

		AddHandler _fontCheckBox.CheckedChanged, AddressOf _fontCheckBox_CheckedChanged
	End Sub

	Private Sub _fontCheckBox_CheckedChanged(sender As Object, e As EventArgs)
		_gcZoom1.ZoomFactor = 1.0F
		_zoomPolicy.ZoomCellStyleFont = _fontCheckBox.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)

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

		Me.Controls.Add(_dataGridView)
		Me.Controls.Add(_fontCheckBox)
	End Sub
End Class