)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to zoom in and zoom out in the WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019
Tags: zooming

Zooming

You can implement the zoom functionality in the GridControl by increasing or decreasing the font size, column widths and row heights proportionally.

The following code example illustrates the Zoom down functionality in GridControl on button click.

C#

private void button2_Click(object sender, System.EventArgs e)
{
 //down
 this.gridControl1.BeginUpdate();
 this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Size *= down;
 this.gridControl1.DefaultColWidth = (int) (down * this.gridControl1.DefaultColWidth);
 this.gridControl1.ColWidths[0] = (int) (down * this.gridControl1.ColWidths[0]);
 this.gridControl1.DefaultRowHeight = (int) (down * this.gridControl1.DefaultRowHeight);
 this.gridControl1.RowHeights[0] = (int) (down * this.gridControl1.RowHeights[0]);
 this.gridControl1.EndUpdate();
 this.gridControl1.Refresh();
}

VB

Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button2.Click
 'down
 Me.gridControl1.BeginUpdate()
 Me.gridControl1.BaseStylesMap("Standard").StyleInfo.Font.Size *= down
 Me.gridControl1.DefaultColWidth = CInt(Fix(down * Me.gridControl1.DefaultColWidth))
 Me.gridControl1.ColWidths(0) = CInt(Fix(down * Me.gridControl1.ColWidths(0)))
 Me.gridControl1.DefaultRowHeight = CInt(Fix(down * Me.gridControl1.DefaultRowHeight))
 Me.gridControl1.RowHeights(0) = CInt(Fix(down * Me.gridControl1.RowHeights(0)))
 Me.gridControl1.EndUpdate()
 Me.gridControl1.Refresh()
End Sub

The following code example illustrates the Zoom up functionality in GridControl on button click.

C#

private void button1_Click(object sender, System.EventArgs e)
{
 //up
 this.gridControl1.BeginUpdate();
 this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Size *= up;
 this.gridControl1.DefaultColWidth = (int) (up * this.gridControl1.DefaultColWidth);
 this.gridControl1.ColWidths[0] = (int) (up * this.gridControl1.ColWidths[0]);
 this.gridControl1.DefaultRowHeight = (int) (up * this.gridControl1.DefaultRowHeight);
 this.gridControl1.RowHeights[0] = (int) (up * this.gridControl1.RowHeights[0]);
 this.gridControl1.EndUpdate();
 this.gridControl1.Refresh();
}

VB

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
 'up
 Me.gridControl1.BeginUpdate()
 Me.gridControl1.BaseStylesMap("Standard").StyleInfo.Font.Size *= up
 Me.gridControl1.DefaultColWidth = CInt(Fix(up * Me.gridControl1.DefaultColWidth))
 Me.gridControl1.ColWidths(0) = CInt(Fix(up * Me.gridControl1.ColWidths(0)))
 Me.gridControl1.DefaultRowHeight = CInt(Fix(up * Me.gridControl1.DefaultRowHeight))
 Me.gridControl1.RowHeights(0) = CInt(Fix(up * Me.gridControl1.RowHeights(0)))
 Me.gridControl1.EndUpdate()
 Me.gridControl1.Refresh()
End Sub

The following screenshots illustrate the Zoom up and Zoom down functionality of GridControl.

Zoom up function of gridcontrol

Figure 1: Zoom up function of GridControl

Zoom down function of gridcontrol

Figure 2: Zoom down function of GridControl

Sample:

http://www.syncfusion.com/downloads/support/directtrac/general/WF-14479_How_Zooming_GridControl471662167.zip

Reference link: https://help.syncfusion.com/windowsforms/grid-control/zooming

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon