GrapeCity MultiRow Windows Forms Documentation
EditingCellFormattedValue Property (IEditingCell)
Example 


Gets or sets the formatted value of the cell.
Syntax
Property EditingCellFormattedValue As Object
Dim instance As IEditingCell
Dim value As Object
 
instance.EditingCellFormattedValue = value
 
value = instance.EditingCellFormattedValue
object EditingCellFormattedValue {get; set;}

Property Value

An System.Object that represents the cell value.
Remarks
When a cell that implements the IEditingCell interface is in edit mode, if the user edits the cell value with a UI action (mouse or keyboard), the cell displays the property value. At that time, the cell does not change the Cell.Value property but only changes the EditingCellFormattedValue property. When the user leaves edit mode to commit the edited value, the EditingCellFormattedValue property saves the underlying value.
Example
The following code example shows how to use this property to customize an editable cell. This code example is part of a larger example provided for the IEditingCell interface.
public object EditingCellFormattedValue
        {
            get
            {
                return _editingValue;
            }
            set
            {
                if ((int)value < this.Minimum)
                {
                    value = Minimum;
                }
                else if ((int)value > this.Maximum)
                {
                    value = Maximum;
                }

                if (_editingValue != (int)value)
                {
                    _editingValue = (int)value;

                    // When changing the editing cell's value, the cell should fire EditingCellValueChanged event to 
notify MultiRow control.
                    // When leaving edit mode, MultiRow uses this value as cell's new value.
                    this.OnEditingCellValueChanged(EventArgs.Empty);

                    // Notify MultiRow control to redraw this cell.
                    this.Invalidate();
                }
            }
        }

        public event EventHandler EditingCellValueChanged;
        protected virtual void OnEditingCellValueChanged(EventArgs e)
        {
            if (this.EditingCellValueChanged != null)
            {
                this.EditingCellValueChanged(this, e);
            }
        }

        protected override void OnCellFormatting(CellFormattingEventArgs e)
        {
            // When multiRow repaints cell, the cell gets the paint value.
            // The cell should use the EditingCellFormattedValue property value to paint the cell, if the cell is in edit 
mode.
            // Change the override OnPaint method to customize the cell painting logic for edit status, 
            // if so, overriding OnCellFormatting is not necessary.
            if (this.GcMultiRow.IsCurrentCellInEditMode &&
                this.GcMultiRow.CurrentCell.RowIndex == e.RowIndex && this.GcMultiRow.CurrentCell.CellIndex == 
e.CellIndex)
            {
                e.Value = this.EditingCellFormattedValue;
            }
            base.OnCellFormatting(e);
        }
Public Property EditingCellFormattedValue() As Object Implements IEditingCell.EditingCellFormattedValue
        Get
            Return _editingValue
        End Get
        Set(ByVal value As Object)
            If DirectCast(value, Integer) < Me.Minimum Then
                value = Minimum
            ElseIf DirectCast(value, Integer) > Me.Maximum Then
                value = Maximum
            End If

            If _editingValue <> DirectCast(value, Integer) Then
                _editingValue = DirectCast(value, Integer)

                ' When changing the editing cell's value, the cell should fire the EditingCellValueChanged event to 
notify the MultiRow control.
                ' When leaving edit mode, MultiRow uses this value as the cell's new value.
                Me.OnEditingCellValueChanged(EventArgs.Empty)

                ' Notify MultiRow control redraw this cell.
                Me.Invalidate()
            End If
        End Set
    End Property

    Public Event EditingCellValueChanged As EventHandler Implements IEditingCell.EditingCellValueChanged

    Protected Overridable Sub OnEditingCellValueChanged(ByVal e As EventArgs)
        RaiseEvent EditingCellValueChanged(Me, e)
    End Sub

    Protected Overloads Overrides Sub OnCellFormatting(ByVal e As CellFormattingEventArgs)
        ' When multiRow repaints the cell, the cell gets the paint value.
        ' The cell should use the EditingCellFormattedValue property value to paint the cell, if the cell is in edit 
mode.
        ' You can override the OnPaint method to customize the cell painting logic for edit mode.
        ' If so, overriding OnCellFormatting is not necessary.
        If Me.GcMultiRow.IsCurrentCellInEditMode AndAlso Me.GcMultiRow.CurrentCell.RowIndex = e.RowIndex 
AndAlso Me.GcMultiRow.CurrentCell.CellIndex = e.CellIndex Then
            e.Value = Me.EditingCellFormattedValue
        End If
        MyBase.OnCellFormatting(e)
    End Sub
Requirements

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

See Also

Reference

IEditingCell Interface
IEditingCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.