GrapeCity.Win.MultiRow Namespace > IEditingControl Interface : ZoomFactor Property |
Property ZoomFactor As Single
Dim instance As IEditingControl Dim value As Single instance.ZoomFactor = value value = instance.ZoomFactor
float ZoomFactor {get; set;}
public class ListBoxEditingControl : ListBox, IEditingControl { public ListBoxEditingControl() { this.BorderStyle = BorderStyle.None; } private GcMultiRow _gcMultiRow; // MultiRow sets this property when beginning to edit. The Editing control uses this property. public GcMultiRow GcMultiRow { get { return _gcMultiRow; } set { _gcMultiRow = value; } } private int _rowIndex; // MultiRow sets this property when beginning to edit. The Editing control uses this property. public int RowIndex { get { return _rowIndex; } set { _rowIndex = value; } } // 1. When beginning to edit, MultiRow should initialize this property. // 2. When ending the edit, MultiRow uses this property value as the cell value. public object FormattedValue { get { return this.Text; } set { if (value == null) { this.Text = string.Empty; } else { this.Text = value.ToString(); } } } // When the user presses Ctrl and wheel mouse wheel button, MultiRow is zoomed. // MultiRow changes this property value when zooming. // EditingControl should do something to fit the new zoom factor, for example, change the font. private float _zoomFactor; private Font _initializeFont = null; public float ZoomFactor { get { return _zoomFactor; } set { this._zoomFactor = value; if (_zoomFactor != 1 && _initializeFont != null) { this.Font = new Font(_initializeFont.FontFamily, _initializeFont.Size * _zoomFactor); } } } public Cursor EditingPanelCursor { get { return Cursors.Default; } } // The keys handled by the editing control. public bool WantsInputKey(Keys keyData) { // The editing control will handle up and down keys. if (keyData == Keys.Up || keyData == Keys.Down) { return true; } return false; } public void PrepareEditingControlForEdit(bool selectAll) { // Do some thing to prepare edit for editing control. } // Apply style. public void ApplyCellStyleToEditingControl(CellStyle cellStyle) { this.BackColor = Color.FromArgb(255, cellStyle.BackColor); this.ForeColor = Color.FromArgb(255, cellStyle.ForeColor); _initializeFont = cellStyle.Font; if (this._zoomFactor != 1) { this.Font = new Font(_initializeFont.FontFamily, _initializeFont.Size * _zoomFactor); } } // When the value has been edited, editing control should fire DirtyStateChanged event to notify MultiRow control. protected override void OnSelectedIndexChanged(EventArgs e) { base.OnSelectedIndexChanged(e); this.OnDirtyStateChanged(EventArgs.Empty); } protected virtual void OnDirtyStateChanged(EventArgs e) { if (this.DirtyStateChanged != null) { this.DirtyStateChanged(this, e); } } public event EventHandler DirtyStateChanged; }
Public Class ListBoxEditingControl Inherits ListBox Implements IEditingControl Public Sub New() Me.BorderStyle = BorderStyle.None End Sub Private _gcMultiRow As GcMultiRow ' MultiRow sets this property when beginning to edit. The Editing control uses this property. Public Property GcMultiRow() As GcMultiRow Implements IEditingControl.GcMultiRow Get Return _gcMultiRow End Get Set(ByVal value As GcMultiRow) _gcMultiRow = value End Set End Property Private _rowIndex As Integer ' MultiRow sets this property when beginning to edit. The Editing control uses this property. Public Property RowIndex() As Integer Implements IEditingControl.RowIndex Get Return _rowIndex End Get Set(ByVal value As Integer) _rowIndex = value End Set End Property ' 1. When beginning to edit, MultiRow should initialize this property. ' 2. When ending the edit, MultiRow uses this property value as the cell value. Public Property FormattedValue() As Object Implements IEditingControl.FormattedValue Get Return Me.Text End Get Set(ByVal value As Object) If value = Nothing Then Me.Text = String.Empty Else Me.Text = value.ToString() End If End Set End Property ' When the user presses Ctrl and wheel mouse wheel button, MultiRow is zoomed. ' MultiRow changes this property's value when zooming. ' EditingControl should do something to fit the new zoom factor, for example, change the font. Private _zoomFactor As Single Private _initializeFont As Font = Nothing Public Property ZoomFactor() As Single Implements IEditingControl.ZoomFactor Get Return _zoomFactor End Get Set(ByVal value As Single) Me._zoomFactor = value If _zoomFactor <> 1 AndAlso Not _initializeFont Is Nothing Then Me.Font = New Font(_initializeFont.FontFamily, _initializeFont.Size * _zoomFactor) End If End Set End Property Public ReadOnly Property EditingPanelCursor() As Cursor Implements IEditingControl.EditingPanelCursor Get Return Cursors.Default End Get End Property ' The keys handled by the editing control. Public Function WantsInputKey(ByVal keyData As Keys) As Boolean Implements IEditingControl.WantsInputKey ' The editing control will handle up and down keys. If keyData = Keys.Up OrElse keyData = Keys.Down Then Return True End If Return False End Function Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) Implements IEditingControl.PrepareEditingControlForEdit ' Do something to prepare for the editing control. End Sub ' Apply style. Public Sub ApplyCellStyleToEditingControl(ByVal cellStyle As CellStyle) Implements IEditingControl.ApplyCellStyleToEditingControl Me.BackColor = Color.FromArgb(255, cellStyle.BackColor) Me.ForeColor = Color.FromArgb(255, cellStyle.ForeColor) _initializeFont = cellStyle.Font If Me._zoomFactor <> 1 Then Me.Font = New Font(_initializeFont.FontFamily, _initializeFont.Size * _zoomFactor) End If End Sub ' When the value has been edited, editing control should fire DirtyStateChanged event to notify MultiRow control. Protected Overloads Overrides Sub OnSelectedIndexChanged(ByVal e As EventArgs) MyBase.OnSelectedIndexChanged(e) Me.OnDirtyStateChanged(EventArgs.Empty) End Sub Protected Overridable Sub OnDirtyStateChanged(ByVal e As EventArgs) RaiseEvent DirtyStateChanged(Me, e) End Sub Public Event DirtyStateChanged As EventHandler Implements IEditingControl.DirtyStateChanged End Class
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2