GrapeCity MultiRow Windows Forms Documentation
Zooming

The GcMultiRow control supports magnifying and scaling down (zooming in or out) the contents.

Allow User to Zoom

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.

Using Code

This example sets the AllowUserToZoom property to True.

[VB]

GcMultiRow1.AllowUserToZoom = True

[CS]

gcMultiRow1.AllowUserToZoom = true;

To restrict zooming by the user, set the GcMultiRow.AllowUserToZoom property to False.

Get or Set Zoom Factor

Developers can get or set the current grid zoom factor using the GcMultiRow.ZoomFactor property.

Using Code

The following code sets the zoom factor of the GcMultiRow control to 200%.

[VB]

GcMultiRow1.ZoomFactor = 2.0F

[CS]

gcMultiRow1.ZoomFactor = 2.0f;

The following code assigns the Ctrl + arrow key to zoom in, and Ctrl + to zoom out.

[VB]

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

[CS]

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;
        }
    }
}
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options