Articles in this section
Category / Section

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

1 min read

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied