Class DataGridViewNumericUpDownCell
Defines a NumericUpDown cell type for the System.Windows.Forms.DataGridView control
Inheritance
DataGridViewNumericUpDownCell
Assembly: Reportman.Drawing.Forms.dll
public class DataGridViewNumericUpDownCell : DataGridViewTextBoxCell, ICloneable, IDisposable
Constructors
Constructor for the DataGridViewNumericUpDownCell cell type
Declaration
public DataGridViewNumericUpDownCell()
Properties
The DecimalPlaces property replicates the one from the NumericUpDown control
Declaration
public int DecimalPlaces { get; set; }
Property Value
Define the type of the cell's editing control
Declaration
public override Type EditType { get; }
Property Value
Overrides
The Increment property replicates the one from the NumericUpDown control
Declaration
public decimal Increment { get; set; }
Property Value
The Maximum property replicates the one from the NumericUpDown control
Declaration
public decimal Maximum { get; set; }
Property Value
The Minimum property replicates the one from the NumericUpDown control
Declaration
public decimal Minimum { get; set; }
Property Value
The ThousandsSeparator property replicates the one from the NumericUpDown control
Declaration
public bool ThousandsSeparator { get; set; }
Property Value
Returns the type of the cell's Value property
Declaration
public override Type ValueType { get; }
Property Value
Overrides
Methods
Clones a DataGridViewNumericUpDownCell cell, copies all the custom properties.
Declaration
public override object Clone()
Returns
Overrides
DetachEditingControl gets called by the DataGridView control when the editing session is ending
Declaration
public override void DetachEditingControl()
Overrides
Customized implementation of the GetErrorIconBounds function in order to draw the potential
error icon next to the up/down buttons and not on top of them.
Declaration
protected override Rectangle GetErrorIconBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
Parameters
Returns
Overrides
GetFormattedValue(object, int, ref DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts)
Customized implementation of the GetFormattedValue function in order to include the decimal and thousand separator
characters in the formatted representation of the cell value.
Declaration
protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
Parameters
Returns
Overrides
Custom implementation of the GetPreferredSize function. This implementation uses the preferred size of the base
DataGridViewTextBoxCell cell and adds room for the up/down buttons.
Declaration
protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
Parameters
Returns
Overrides
Custom implementation of the InitializeEditingControl function. This function is called by the DataGridView control
at the beginning of an editing session. It makes sure that the properties of the NumericUpDown editing control are
set according to the cell properties.
Declaration
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
Parameters
Overrides
Custom implementation of the KeyEntersEditMode function. This function is called by the DataGridView control
to decide whether a keystroke must start an editing session or not. In this case, a new session is started when
a digit or negative sign key is hit.
Declaration
public override bool KeyEntersEditMode(KeyEventArgs e)
Parameters
Returns
Overrides
Custom paints the cell. The base implementation of the DataGridViewTextBoxCell type is called first,
dropping the icon error and content foreground parts. Those two parts are painted by this custom implementation.
In this sample, the non-edited NumericUpDown control is painted by using a call to Control.DrawToBitmap. This is
an easy solution for painting controls but it's not necessarily the most performant. An alternative would be to paint
the NumericUpDown control piece by piece (text and up/down buttons).
Declaration
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
Parameters
Overrides
DataGridViewTextBoxCell.Paint(Graphics, Rectangle, Rectangle, int, DataGridViewElementStates, object, object, string, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle, DataGridViewPaintParts)
Custom implementation of the PositionEditingControl method called by the DataGridView control when it
needs to relocate and/or resize the editing control.
Declaration
public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
Parameters
Overrides
Returns a standard textual representation of the cell.
Declaration
public override string ToString()
Returns
Overrides
Implements