| MultiRow Windows Forms > Developer's Guide > Using MultiRow > Grid > Zooming |
The GcMultiRow control supports magnifying and scaling down (zooming in or out) the contents.
The user can zoom in and out of the grid contents by scrolling the mouse wheel in the forward and backward direction while pressing the Ctrl key when the GcMultiRow.AllowUserToZoom property has been set to True.
This example sets the AllowUserToZoom property to True.
GcMultiRow1.AllowUserToZoom = True |
gcMultiRow1.AllowUserToZoom = true; |
To restrict zooming by the user, set the GcMultiRow.AllowUserToZoom property to False.
Developers can get or set the current grid zoom factor using the GcMultiRow.ZoomFactor property.
The following code sets the zoom factor of the GcMultiRow control to 200%.
GcMultiRow1.ZoomFactor = 2.0F |
gcMultiRow1.ZoomFactor = 2.0f; |
The following code assigns the Ctrl + ↑ arrow key to zoom in, and Ctrl + ↓ to zoom out.
Imports GrapeCity.Win.MultiRow
GcMultiRow1.ShortcutKeyManager.Register(New ZoomInAction(), Keys.Control Or Keys.Up)
GcMultiRow1.ShortcutKeyManager.Register(New ZoomOutAction(), Keys.Control Or Keys.Down)
Public Class ZoomInAction
Implements IAction
Public Function CanExecute(ByVal target As GcMultiRow) As Boolean _
Implements IAction.CanExecute
If target.AllowUserToZoom = True Then
Return True
End If
Return False
End Function
Public ReadOnly Property DisplayName() As String _
Implements IAction.DisplayName
Get
Return Me.ToString()
End Get
End Property
Public Sub Execute(ByVal target As GcMultiRow) _
Implements IAction.Execute
Try
target.ZoomFactor *= 2
Catch ex As Exception
Throw
End Try
End Sub
End Class
Public Class ZoomOutAction
Implements IAction
Public Function CanExecute(ByVal target As GcMultiRow) As Boolean _
Implements IAction.CanExecute
If target.AllowUserToZoom = True Then
Return True
End If
Return False
End Function
Public ReadOnly Property DisplayName() As String _
Implements IAction.DisplayName
Get
Return Me.ToString()
End Get
End Property
Public Sub Execute(ByVal target As GcMultiRow) _
Implements IAction.Execute
Try
target.ZoomFactor /= 2
Catch ex As Exception
Throw
End Try
End Sub
End Class
|
using GrapeCity.Win.MultiRow;
gcMultiRow1.ShortcutKeyManager.Register(new ZoomInAction(), Keys.Control | Keys.Up);
gcMultiRow1.ShortcutKeyManager.Register(new ZoomOutAction(), Keys.Control | Keys.Down);
public class ZoomInAction : IAction
{
public bool CanExecute(GcMultiRow target)
{
if (target.AllowUserToZoom == true)
return true;
return false;
}
public string DisplayName
{
get { return this.ToString(); }
}
public void Execute(GcMultiRow target)
{
try
{
target.ZoomFactor *= 2;
}
catch (Exception)
{
throw;
}
}
}
public class ZoomOutAction : IAction
{
public bool CanExecute(GcMultiRow target)
{
if (target.AllowUserToZoom == true)
return true;
return false;
}
public string DisplayName
{
get { return this.ToString(); }
}
public void Execute(GcMultiRow target)
{
try
{
target.ZoomFactor /= 2;
}
catch (Exception)
{
throw;
}
}
}
|