HypernovaDesktop Components · docs
Binarymission
WinForms › Tree List View › BinaryTreeListViewNumericUpDownCell

BinaryTreeListViewNumericUpDownCell

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.TreeControls

A cell of a BinaryTreeListViewNumericUpDownColumn: it holds a decimal, shows it with the column's decimal places and thousands separator, and is edited in a spinner.

public class BinaryTreeListViewNumericUpDownCell : DataGridViewTextBoxCell

Inherits from / implements: DataGridViewTextBoxCell

Remarks

The column creates its cells from its template and its settings apply to every cell, so set BinaryTreeListViewNumericUpDownColumn.Minimum, BinaryTreeListViewNumericUpDownColumn.Maximum and the rest on the column. The same properties on one cell change that cell only.

The value is held between Minimum and Maximum: narrowing the range moves a value that falls outside it to the nearer end.

See also

Members at a glance

Constructors
BinaryTreeListViewNumericUpDownCellCreates a cell for whole numbers from 0 to 100, stepped by 1, without a thousands separator. The column creates its cells from its template, so an application rarely calls this.
Properties
DecimalPlacesGets or sets how many decimal places the cell shows and the spinner edits.
EditTypeGets the type of the editor the grid shows while the cell is edited.
IncrementGets or sets how much one click on a spin button, or one press of Up or Down, changes the value.
MaximumGets or sets the largest value the cell can hold.
MinimumGets or sets the smallest value the cell can hold.
ThousandsSeparatorGets or sets whether the value is shown with the current culture's group separator, as in 12,500.
ValueTypeGets the type of the value the cell holds.
Methods
CloneCreates a copy of the cell, including its range, increment, decimal places and separator setting.
DetachEditingControlEnds the cell's use of the grid's editor when editing finishes, clearing the editor's undo history so it does not carry into the next cell edited.
GetErrorIconBoundsReturns where the cell's error icon is drawn: beside the spin buttons rather than on top of them.
GetFormattedValueFormats the value for display with the cell's DecimalPlaces, and with group separators when ThousandsSeparator is set – 1234.5 with two places and the separator shows as 1,234.50.
GetPreferredSizeReturns the size the cell needs: the size of its text, plus room for the spin buttons when the width is not constrained.
InitializeEditingControlPrepares the grid's spinner for this cell as an edit starts: the cell's range, increment, decimal places and separator, the column's colours and look, and the cell's current text.
KeyEntersEditModeReports whether a key typed on the cell starts an edit: a digit on the main keys or the keypad, or the minus sign, pressed without Shift, Ctrl or Alt.
PaintPaints the cell: its value, and the spinner's chrome on rows that are not being edited when the grid shows editors on every row.
PositionEditingControlPlaces the spinner in the cell while it is edited: one pixel in from each side, and centred or bottom-aligned to match the cell's alignment when the row is taller than the text.
ToStringReturns a short description of the cell, with its column and row index.

Constructors

BinaryTreeListViewNumericUpDownCell

public BinaryTreeListViewNumericUpDownCell()

Creates a cell for whole numbers from 0 to 100, stepped by 1, without a thousands separator. The column creates its cells from its template, so an application rarely calls this.

Properties

DecimalPlaces

public int DecimalPlaces

Gets or sets how many decimal places the cell shows and the spinner edits.

Value
From 0 to 99. The default is 0.
Default
DATAGRIDVIEWNUMERICUPDOWNCELL_defaultDecimalPlaces
Exceptions
ArgumentOutOfRangeException
The value is below 0 or above 99.
Remarks

Changing it repaints the cell and, if the column sizes itself to its content, resizes it.

See also

EditType

public override Type EditType

Gets the type of the editor the grid shows while the cell is edited.

Value
An internal type based on BinaryNumericUpDown; the grid creates one and reuses it.

Increment

public Decimal Increment

Gets or sets how much one click on a spin button, or one press of Up or Down, changes the value.

Value
Zero or more. The default is 1.
Exceptions
ArgumentOutOfRangeException
The value is negative.

Maximum

public Decimal Maximum

Gets or sets the largest value the cell can hold.

Value
The default is 100.
Remarks

A value above the new maximum is lowered to it, and a Minimum above it is lowered to match.

See also

Minimum

public Decimal Minimum

Gets or sets the smallest value the cell can hold.

Value
The default is 0.
Remarks

A value below the new minimum is raised to it, and a Maximum below it is raised to match.

See also

ThousandsSeparator

public bool ThousandsSeparator

Gets or sets whether the value is shown with the current culture's group separator, as in 12,500.

Value
true to group the digits; the default is false.
Default
DATAGRIDVIEWNUMERICUPDOWNCELL_defaultThousandsSeparator
See also

ValueType

public override Type ValueType

Gets the type of the value the cell holds.

Value
decimal, unless a different value type has been set on the cell or its column.

Methods

Clone

public override object Clone()

Creates a copy of the cell, including its range, increment, decimal places and separator setting.

Returns

DetachEditingControl

public override void DetachEditingControl()

Ends the cell's use of the grid's editor when editing finishes, clearing the editor's undo history so it does not carry into the next cell edited.

Exceptions
InvalidOperationException
The cell is not in a grid, or the grid has no editor at the moment.

GetErrorIconBounds

protected override Rectangle GetErrorIconBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)

Returns where the cell's error icon is drawn: beside the spin buttons rather than on top of them.

Parameters
graphics
The surface being painted.
cellStyle
The cell's style.
rowIndex
The grid row of the cell.
Returns

The icon's bounds, moved clear of the spin buttons on the side they are drawn.

GetFormattedValue

protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)

Formats the value for display with the cell's DecimalPlaces, and with group separators when ThousandsSeparator is set – 1234.5 with two places and the separator shows as 1,234.50.

Parameters
value
The value held by the cell.
rowIndex
The grid row of the cell.
cellStyle
The style in force, which the grid's CellFormatting event may have changed.
valueTypeConverter
A converter for the stored type, or null.
formattedValueTypeConverter
A converter for the display type, or null.
context
Why the value is being formatted.
Returns

The text to show. When a CellFormatting handler has already changed the text, its result is kept as it is.

GetPreferredSize

protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)

Returns the size the cell needs: the size of its text, plus room for the spin buttons when the width is not constrained.

Parameters
graphics
The surface the cell is measured on.
cellStyle
The cell's style.
rowIndex
The grid row of the cell.
constraintSize
The width or height the cell must fit, or Size.Empty.
Returns

The preferred size, or (-1, -1) when the cell is not in a grid.

InitializeEditingControl

public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)

Prepares the grid's spinner for this cell as an edit starts: the cell's range, increment, decimal places and separator, the column's colours and look, and the cell's current text.

Parameters
rowIndex
The grid row of the cell being edited.
initialFormattedValue
The text the spinner starts with, or null for an empty one.
dataGridViewCellStyle
The cell's style.

KeyEntersEditMode

public override bool KeyEntersEditMode(KeyEventArgs e)

Reports whether a key typed on the cell starts an edit: a digit on the main keys or the keypad, or the minus sign, pressed without Shift, Ctrl or Alt.

Parameters
e
The key that was pressed.
Returns

true when the key starts an edit; F2 and the grid's other edit triggers work as in any cell.

Paint

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)

Paints the cell: its value, and the spinner's chrome on rows that are not being edited when the grid shows editors on every row.

Remarks

With BinaryTreeListView.SpecialColumnCellsToDisplayEditingControlOnCellsAlways on, a row that is not being edited shows the spinner's chrome beside its value. With the column's BinaryTreeListViewNumericUpDownColumn.DrawStyleIsFlat on – its default – that is a flat pair of chevrons in the column's colours, inside a hairline box when BinaryTreeListViewNumericUpDownColumn.ShowBorderAlways is on. Off, it is the classic 3D spinner picture.

PositionEditingControl

public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)

Places the spinner in the cell while it is edited: one pixel in from each side, and centred or bottom-aligned to match the cell's alignment when the row is taller than the text.

ToString

public override string ToString()

Returns a short description of the cell, with its column and row index.

Returns

Text of the form BinaryTreeListViewNumericUpDownCell { ColumnIndex=2, RowIndex=5 }.