BinaryTreeListViewNumericUpDownCell
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 | |
|---|---|
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 | Gets or sets how many decimal places the cell shows and the spinner edits. |
EditType | Gets the type of the editor the grid shows while the cell is edited. |
Increment | Gets or sets how much one click on a spin button, or one press of Up or Down, changes the value. |
Maximum | Gets or sets the largest value the cell can hold. |
Minimum | Gets or sets the smallest value the cell can hold. |
ThousandsSeparator | Gets or sets whether the value is shown with the current culture's group separator, as in 12,500. |
ValueType | Gets the type of the value the cell holds. |
| Methods | |
Clone | Creates a copy of the cell, including its range, increment, decimal places and separator setting. |
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. |
GetErrorIconBounds | Returns where the cell's error icon is drawn: beside the spin buttons rather than on top of them. |
GetFormattedValue | 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. |
GetPreferredSize | Returns the size the cell needs: the size of its text, plus room for the spin buttons when the width is not constrained. |
InitializeEditingControl | 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. |
KeyEntersEditMode | 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. |
Paint | 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. |
PositionEditingControl | 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 | Returns a short description of the cell, with its column and row index. |
Constructors
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
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
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
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
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
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
Gets or sets whether the value is shown with the current culture's group separator, as in 12,500.
- Value
trueto group the digits; the default isfalse.- Default
DATAGRIDVIEWNUMERICUPDOWNCELL_defaultThousandsSeparator
See also
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
Creates a copy of the cell, including its range, increment, decimal places and separator setting.
Returns
The new BinaryTreeListViewNumericUpDownCell.
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
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
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
CellFormattingevent 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
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
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
nullfor an empty one. dataGridViewCellStyle- The cell's style.
KeyEntersEditMode
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
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
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
Returns a short description of the cell, with its column and row index.
Returns
Text of the form BinaryTreeListViewNumericUpDownCell { ColumnIndex=2, RowIndex=5 }.