Class GridNumericUpDownCellRenderer
Defines the renderer part of a numeric up / down cell that lets users increase and decrease values with spin buttons.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridNumericUpDownCellRenderer : GridTextBoxCellRenderer, IQueryFocusInside, IGridDropDownCell, IPopupParent, IPopupItem, IDisposable
Remarks
A GridNumericUpDownCellRenderer cell's behavior can be customized with the NumericUpDown property of a GridStyleInfo instance and any properties that affect regular text boxes as specified for GridTextBoxCellRenderer and GridStaticCellRenderer.
NumericUpDown lets you specify the step, minimum and maximum value, and if the value should start over when you reach the maximum value.
GridNumericUpDownCellRenderer displays two GridCellUpDownButton cell button elements at the right side of the cell. You can specify when these buttons are shown with the ShowButtons property of a GridStyleInfo instance.
You can disable these buttons when you reset the Clickable property of GridStyleInfo to False.
A renderer is created for each GridCellModelBase and GridControlBase. There can be several renderers associated with one GridNumericUpDownCellModel if several views display the same GridModel.
The up-down buttons are XP Themes enabled. They will be drawn themed if ThemesEnabled is true.
The following table lists some characteristics about the NumericUpDown cell type:
Item | Description |
---|---|
CellType | NumericUpDown |
Renderer | GridNumericUpDownCellRenderer |
Model | GridNumericUpDownCellModel |
XP Themes Support | Yes |
Cell Button | GridCellUpDownButton |
Interactive | Edit with Text Input or click on Up-/Down Buttons |
Control | GridTextBoxControl |
Floating Support | No |
Base Type | GridTextBoxCellRenderer |
The cells behavior and appearance can be customized with the following properties of the GridStyleInfo class:
PropertyName | Description |
---|---|
AllowEnter (System.Boolean) | Gets / sets if pressing the <Enter>-Key should insert a new line into the edited text. (Default: False) |
AutoSize (System.Boolean) | Gets / sets if the cell height should automatically increase when the edited text does not fit into the cell and WrapText is True. If WrapText is False, AutoSize will affect the column width. (Default: False) |
BaseStyle (System.String) | The base style for this style instance with default values for properties that are not initialized for this style object. (Default: String.Empty) |
Borders (GridBordersInfo) | Top, left, bottom, and right border settings. (Default: GridBordersInfo.Default) |
CellAppearance (GridCellAppearance) | Specifies if cell edges shall be drawn raised, sunken, or flat (default). (Default: GridCellAppearance.Flat) |
CellTipText (System.String) | ToolTip text to be displayed when user hovers mouse over cell. (Default: String.Empty) |
CellType (System.String) | NumericUpDown (Default: Text Box) |
CellValue (System.Object) | This property holds the cell value. Although the cell value is typically a string, it can also be any other primitive type such as int, byte, enum, or any custom type that is derived from System.Object. (Default: String.Empty) |
CellValueType (System.Type) | Specifies the preferred System.Type for cell values. When you assign a value to the GridStyleInfo object, the value will be converted to this type. If the value cannot be converted, Error will contain error information. (Default: NULL) |
Clickable (System.Boolean) | Specifies if up / down buttons can be clicked. If set to False, the buttons will be drawn grayed out. See Enabled to disable activating the cell as current cell. (Default: True) |
CultureInfo (System.Globalization.CultureInfo) | The culture information holds rules for parsing and formatting the cells value. (Default: NULL) |
Enabled (System.Boolean) | Specifies if the cell can be activated as current cell or if cell should be skipped when moving the current cell. When disabled, the up / down buttons will be drawn grayed out. (Default: True) |
Error (System.String) | Holds error information if a value could not be converted to the System.Type specified with CellValueType. (Default: String.Empty) |
Font (GridFontInfo) | The font for drawing text. (Default: GridFontInfo.Default) |
Format (System.String) | Gets / sets the format mask for formatting the cell value. You can specify numeric format strings, date format strings, or enumeration format strings as discussed in the section "Format Specifiers and Format Providers" of the .NET Framework Developers Guide (see ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconformatspecifiersformatproviders.htm) (Default: String.Empty) |
HorizontalAlignment (GridHorizontalAlignment) | Specifies the horizontal alignment of text in the cell. This does not affect the position of the up / down buttons. (Default: GridHorizontalAlignment.Left) |
HotkeyPrefix (System.Drawing.Text.HotkeyPrefix) | Specifies how hot-key prefixes should be displayed. Hot-keys are indicated in text with an '&' (ampersand). When you enable the hot-key prefix, the specific characters can be displayed underlined or regular. The '&' will not be displayed. (Default: HotkeyPrefix.Show) |
ImageIndex (System.Int32) | Specifies an index for an image in the ImageList of a GridStyleInfo instance. (Default: -1) |
ImageList (System.Windows.Forms.ImageList) | The ImageList that holds a collection of images. Cells can choose images with the ImageIndex property in a GridStyleInfo instance. (Default: NULL) |
Interior (BrushInfo) | Lets you specify a solid backColor, gradient, or pattern style with both back and foreColor for a cell's background. (Default: SystemColors.Window) |
MaxLength (System.Int32) | Limits the number of characters the user can type into the cell. Note: When selecting a text from a choice list or when pasting text, the text can be longer. Additional validation is necessary on your side. (Default: 0) |
NumericUpDown (GridNumericUpDownCellInfo) | NumericUpDown lets you specify the step, minimum and maximum value, and if the value should start over when you reach the maximum value. (Default: NULL) |
ReadOnly (System.Boolean) | Specifies if cell contents can be modified by the user. You can programmatically change Read-only cells by setting DiscardReadOnly to True. (Default: False) |
ShowButtons (GridShowButtons) | Specifies when to show or display the drop-down button. Possible choices are: show the button only for the current cell, always show buttons, or never show buttons. (Default: GridShowButtons.Show) |
Text (System.String) | Gets / sets the value as a string. If a CellValueType is specified, the text will be parsed and converted to the type specified with CellValueType using any CultureInfo information. (Default: String.Empty) |
TextAlign (GridTextAlign) | Align text left of button elements (which is typical for NumericUpDown). Or align text right of button elements. (Default: GridTextAlign.Default) |
TextColor (System.Drawing.Color) | Lets you specify the color for drawing the cell text. (Default: SystemColors.WindowText) |
TextMargins (GridMarginsInfo) | Holds text margins in pixels. When drawing a cell, this specifies the empty area between the text rectangle and the borders of the client rectangle of the cell. The client rectangle is the cell rectangle without buttons and borders. (Default: GridMarginsInfo.Default) |
Themed (System.Boolean) | Specifies if cell should be drawn using Windows XP themes when ThemesEnabled has been set. (Default: True) |
Trimming (System.Drawing.StringTrimming) | Indicates how text is trimmed when it exceeds the edges of the cell text rectangle. (Default: StringTrimming.Character) |
ValidateValue (GridCellValidateValueInfo) | Holds validation rules for the cell values that are being checked before any user changes are committed to the grid cells style object. (Default: null) |
VerticalAlignment (GridVerticalAlignment) | Specifies vertical alignment of text and the up / down buttons in the cell. (Default: GridVerticalAlignment.Top) |
WrapText (System.Boolean) | Specifies if text should be wrapped when it does not fit into a single line. (Default: True) |
Constructors
GridNumericUpDownCellRenderer(GridControlBase, GridCellModelBase)
Initializes a new GridNumericUpDownCellRenderer object for the given GridControlBase and GridNumericUpDownCellModel.
Declaration
public GridNumericUpDownCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The GridControlBase that displays this cell renderer. |
GridCellModelBase | cellModel | The GridNumericUpDownCellModel that holds data for this cell renderer that should be shared among views. |
Remarks
References to GridControlBase and GridCellModelBase will be saved.
Methods
OnButtonClicked(Int32, Int32, Int32)
This method is called when the user clicks a cell button inside cell.
Declaration
protected override void OnButtonClicked(int rowIndex, int colIndex, int button)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Int32 | button | The button |
Overrides
Remarks
In your overridden version of this method, you can activate the current cell for the given row and column index and then drop-down a list.
OnInitialize(Int32, Int32)
Called from Initialize after currentRowIndex, inInitialize are set and PerformLayout finished.
Declaration
protected override void OnInitialize(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
Overrides
OnLayout(Int32, Int32, GridStyleInfo, Rectangle, Rectangle[])
This method is called from PerformLayout to calculate the client rectangle given the inner rectangle of a cell and any boundaries of cell buttons.
Declaration
protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridStyleInfo | style | The GridStyleInfo object that holds cell information. |
System.Drawing.Rectangle | innerBounds | The System.Drawing.Rectangle with the inner bounds of a cell. |
System.Drawing.Rectangle[] | buttonsBounds | An array of System.Drawing.Rectangle with bounds for each cell button element. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | A System.Drawing.Rectangle with the bounds. |
Overrides
ValidateString(String)
Checks whether the specified text is valid.
Declaration
public override bool ValidateString(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to be validated. |
Returns
Type | Description |
---|---|
System.Boolean | True if the given text is valid; False otherwise. |