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 change the editing cell's value, the cell should fire EditingCellValueChanged event to notify MultiRow control.
// So that, when leave editing status, MultiRow control can use this value as cell's new value.
this.OnEditingCellValueChanged(EventArgs.Empty);
// Notify MultiRow control 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 control repaint cell, the cell will get the paint value.
// The cell should use the EditingCellFormattedValue property value to paint cell, if cell in editing status.
// You also change override OnPaint method to customize the cell painting logic for edit status,
// if so, override 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 change the editing cell's value, the cell should fire EditingCellValueChanged event to notify MultiRow control.
' So that, when leave editing status, MultiRow control can use this value as 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 control repaint cell, the cell will get the paint value.
' The cell should use the EditingCellFormattedValue property value to paint cell, if cell in editing status.
' You also change override OnPaint method to customize the cell painting logic for edit status,
' if so, override 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