Class GridCheckBoxCellRenderer
Implements the renderer part for a check box cell.
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridCheckBoxCellRenderer : GridCellRendererBase, IQueryFocusInside, IGridDropDownCell, IPopupParent, IPopupItem, IDisposable
Remarks
A GridCheckBoxCellRenderer cell's behavior can be customized with the CheckBoxOptions property of a GridStyleInfo instance where you can specify values for Checked, Unchecked, and Indeterminate. The TriState property of a GridStyleInfo instance lets you toggle tri-state behavior for the cell.
The check box cell is XP Themes enabled. It will be drawn themed if ThemesEnabled is True.
A renderer is created for each GridCellModelBase and GridControlBase. There can be several renderers associated with one GridCheckBoxCellModel if several views display the same GridModel.
Use "Check Box" as identifier in CellType of a cell's GridStyleInfo to associate this cell type with a cell.
The following table lists some characteristics about the Check Box cell type:
Item | Description |
---|---|
CellType | Check Box |
Renderer | GridCheckBoxCellRenderer |
Model | GridCheckBoxCellModel |
XP Themes Support | Yes |
Interactive | Edit with Mouse Click or SpaceBar |
Floating Support | Floating |
Base Type | GridCellRendererBase |
The cell's behavior and appearance can be customized with the following properties of the GridStyleInfo class:
PropertyName | Description |
---|---|
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) | Check Box (Default: Text Box) |
CellValue (System.Object) | The cell value should match one of the values of GridCheckBoxCellInfo. (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) |
CheckBoxOptions (GridCheckBoxCellInfo) | Gets / sets flat look and values that represent checked, unchecked, and indeterminate state of the check box. (Default: NULL) |
Description (System.String) | Gets / sets the text that is shown in the check box. (Default: String.Empty) |
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 check box will be drawn grayed out. (Default: True) |
Font (GridFontInfo) | The font for drawing text. (Default: GridFontInfo.Default) |
HorizontalAlignment (GridHorizontalAlignment) | Specifies horizontal alignment of text and the checkbox in the cell. (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 hot-key prefix, the specific characters can be displayed underlined or regular. The '&' will not be displayed. The Description of a check box can have hotkeys. (Default: HotkeyPrefix.Show) |
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) |
MaskEdit (GridMaskEditInfo) | Gets / sets MaskedEdit state. MaskedEdit is itself an expandable object with several properties that can be set individually and participate in style inheritance mechanism. (Default: GridMaskEditInfo.Default) |
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) |
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. The cell value should match one of the values provided by GridCheckBoxCellInfo. (Default: String.Empty) |
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 including the check box and the borders of the cell. (Default: GridMarginsInfo.Default) |
Themed (System.Boolean) | Specifies if cell should be drawn using Windows XP themes when ThemesEnabled has been set. (Default: True) |
TriState (System.Boolean) | Specifies if this is a Tristate check box that has an additional indeterminate state. (Default: False) |
Trimming (System.Drawing.StringTrimming) | Indicates how text is trimmed when it exceeds the edges of the cell text rectangle. (Default: StringTrimming.Character) |
VerticalAlignment (GridVerticalAlignment) | Specifies vertical alignment of text and the check box in the cell. (Default: GridVerticalAlignment.Top) |
WrapText (System.Boolean) | Specifies if the Description text should be wrapped when it does not fit into a single line. (Default: True) |
Constructors
GridCheckBoxCellRenderer(GridControlBase, GridCellModelBase)
Initializes a new GridCheckBoxCellRenderer object for the given GridControlBase and GridCellModelBase.
Declaration
public GridCheckBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The GridControlBase that display this cell renderer. |
GridCellModelBase | cellModel | The GridCheckBoxCellModel that holds data for this cell renderer that should be shared among views. |
Remarks
References to GridControlBase, and GridCellModelBase will be saved.
Properties
CheckBoxSize
Gets or sets CheckBoxSize. For internal use.
Declaration
public Size CheckBoxSize { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
Methods
DetermineCheckBoxBounds(Graphics, Rectangle, String, Font, ContentAlignment, GridMargins, GridTextAlign)
Calculates the checker boundaries taking alignment, margins and style information into account.
Declaration
protected virtual Rectangle DetermineCheckBoxBounds(Graphics g, Rectangle clientBounds, string text, Font font, ContentAlignment align, GridMargins margins, GridTextAlign textAlign)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The System.Drawing.Graphics context of the canvas. |
System.Drawing.Rectangle | clientBounds | Specifies the client rectangle. It is the cell rectangle without buttons and borders. |
System.String | text | The text to display in the check box cell. |
System.Drawing.Font | font | The font for drawing text. |
System.Drawing.ContentAlignment | align | The alignment of check box and text inside cell. |
GridMargins | margins | The margins between check box, text, and the cell borders. |
GridTextAlign | textAlign | Specifies if checker should be left or right of text. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The rectangle with check box bounds. |
Dispose(Boolean)
Unwires any events subscribed from GridCheckBoxCellRenderer.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
Remarks
See the documentation for the System.ComponentModel.Component class and its Dispose member.
DrawCheckBox(Graphics, Rectangle, GridStyleInfo, ButtonState, ContentAlignment, String, Font)
Draws the checker at the given coordinates.
Declaration
protected virtual void DrawCheckBox(Graphics g, Rectangle clientBounds, GridStyleInfo style, ButtonState state, ContentAlignment align, string text, Font font)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | The System.Drawing.Graphics context of the canvas. |
System.Drawing.Rectangle | clientBounds | Specifies the client rectangle. It is the cell rectangle without buttons and borders. |
GridStyleInfo | style | A reference to the style object of the cell. |
System.Windows.Forms.ButtonState | state | The current state of the check box to be drawn. |
System.Drawing.ContentAlignment | align | The alignment of check box and text inside cell. |
System.String | text | The text to display in the checkbox cell. |
System.Drawing.Font | font | The font for drawing text. |
DrawCheckBox(Graphics, Rectangle, ButtonState)
Draws check box at the specified bounds.
Declaration
public static void DrawCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | graphics | Graphics context. |
System.Drawing.Rectangle | rectangle | The Rectangle Bounds. |
System.Windows.Forms.ButtonState | state | Button state. |
DrawCheckBox(Graphics, Int32, Int32, Int32, Int32, ButtonState)
Draws checks at the given bounds.
Declaration
public static void DrawCheckBox(Graphics graphics, int x, int y, int width, int height, ButtonState state)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | graphics | Graphics context. |
System.Int32 | x | X co-ordinate. |
System.Int32 | y | Y co-ordinate. |
System.Int32 | width | Width of the rectangle bounds. |
System.Int32 | height | Height of the rectangle bounds. |
System.Windows.Forms.ButtonState | state | Button state. |
GetCachedCheckerBounds(Int32, Int32)
Returns the checker bounds for the cell at the specified cell coordinates.
Declaration
protected Rectangle GetCachedCheckerBounds(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The System.Drawing.Rectangle with bounds for the checker. |
GetState(Int32, Int32, GridStyleInfo)
Returns the current System.Windows.Forms.ButtonState for the checker for the specified cell.
Declaration
protected ButtonState GetState(int rowIndex, int colIndex, GridStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
GridStyleInfo | style | A reference to the style object of the cell. |
Returns
Type | Description |
---|---|
System.Windows.Forms.ButtonState | The current System.Windows.Forms.ButtonState at the given cell. |
IsCellScope(Int32, Int32)
Determines if the check box at the specified cell coordinates has scope set.
Declaration
public bool IsCellScope(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
Returns
Type | Description |
---|---|
System.Boolean | True if cell has scope; False otherwise. |
OnCancelMode(Int32, Int32)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the mouse operation is canceled.
Declaration
protected override void OnCancelMode(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Overrides
OnClickedCheckBox()
Called when user clicked check box. Toggles the cell's value and stores it back into the cell.
Declaration
protected virtual void OnClickedCheckBox()
OnDraw(Graphics, Rectangle, Int32, Int32, GridStyleInfo)
This method is called from the cell renderer's draw method to draw the contents of the client bounds for the cell, e.g. the text for a static cell.
Declaration
protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.Drawing.Rectangle | clientRectangle | Specifies the client rectangle. It is the cell rectangle without buttons and borders. |
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
GridStyleInfo | style | A reference to the style object of the cell. |
Overrides
Remarks
When drawing cells, it is necessary to determine if the specified cell (with rowIndex and colIndex) is the current cell and if it is active.
If your control is associated with a control and supports in-place editing and the specified cell is the current cell, you should position the control. Take a look at the GridTextBoxCellRenderer implementation of this method for an example.
Otherwise, you can simply draw the cell.
OnHitTest(Int32, Int32, MouseEventArgs, IMouseController)
Overriden. Checks if mouse is inside the checker.
Declaration
protected override int OnHitTest(int rowIndex, int colIndex, MouseEventArgs e, IMouseController controller)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | A System.Windows.Forms.MouseEventArgs with data about the mouse event. |
IMouseController | controller | The current controller that requested to handle this mouse event. |
Returns
Type | Description |
---|---|
System.Int32 | Non-zero if mouse is over the checker; 0 otherwise. |
Overrides
OnKeyPress(KeyPressEventArgs)
User pressed key (similar to Control.OnKeyPress).
Declaration
protected override void OnKeyPress(KeyPressEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.KeyPressEventArgs | e | A System.Windows.Forms.KeyEventArgs with data of the keyboard event. |
Overrides
OnMouseDown(Int32, Int32, MouseEventArgs)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the user has pressed a mouse button.
Declaration
protected override void OnMouseDown(int rowIndex, int colIndex, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | A System.Windows.Forms.MouseEventArgs with event data. |
Overrides
OnMouseHoverEnter(Int32, Int32)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the user has moved the mouse into the cell.
Declaration
protected override void OnMouseHoverEnter(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Overrides
Remarks
See also OnMouseHoverLeave.
OnMouseHoverLeave(Int32, Int32, EventArgs)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the user is moving the mouse out of the cell.
Declaration
protected override void OnMouseHoverLeave(int rowIndex, int colIndex, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.EventArgs | e | An System.EventArgs with event data. |
Overrides
Remarks
Once OnMouseHoveEnter has been called you are guaranteed to receive a OnMouseHoverLeave call either if the user moves the mouse of the cell boundaries or presses a button or if the mouse operation is canceled.
OnMouseMove(Int32, Int32, MouseEventArgs)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the user has pressed a mouse button and is moving the mouse pointer.
Declaration
protected override void OnMouseMove(int rowIndex, int colIndex, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | A System.Windows.Forms.MouseEventArgs with event data. |
Overrides
OnMouseUp(Int32, Int32, MouseEventArgs)
This is called from GridClickCellsMouseController or GridSelectCellsMouseController when your cell renderer has indicated in its OnHitTest override that it wants to receive mouse events and the user has pressed a mouse button and is releasing the button.
Declaration
protected override void OnMouseUp(int rowIndex, int colIndex, MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.Forms.MouseEventArgs | e | A System.Windows.Forms.MouseEventArgs with event data. |
Overrides
OnSaveChanges()
This method is called from GridCurrentCell.ConfirmChanges when the current cell was marked as modified. Any drop-downs have been closed at this time. It saves changes for the current cell.
Declaration
protected override bool OnSaveChanges()
Returns
Type | Description |
---|---|
System.Boolean | True if changes were saved successfully; False if no changes were saved. |
Overrides
SetCellScope(Int32, Int32, Boolean)
Sets scope for the specified cell.
Declaration
public void SetCellScope(int rowIndex, int colIndex, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Specifies the row id. |
System.Int32 | colIndex | Specifies the column id. |
System.Boolean | value | True if cell has scope; False otherwise. |