Class GridStaticCellRenderer
Defines the renderer part of a static cell. A static cell renderer is also a base class for many other cell types and provides the inactive cell rendering for cell types that support editing (such as a text box or combo box).
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridStaticCellRenderer : GridCellRendererBase, IQueryFocusInside, IGridDropDownCell, IPopupParent, IPopupItem, IDisposable
Remarks
A renderer is created for each GridCellModelBase and GridControlBase. There can be several renderers associated with one GridStaticCellModel if several views display the same GridModel.
The following table lists some characteristics about the Static cell type.
Item | Description |
---|---|
CellType | Static |
Renderer | GridStaticCellRenderer |
Model | GridStaticCellModel |
XP Themes Support | NA |
Interactive | Click Only |
Floating Support | Both |
Base Type | GridCellRendererBase |
The cell's behavior and appearance can be customized with the following properties of the GridStyleInfo class.
PropertyName | Description |
---|---|
BackgroundImage (System.Drawing.Image) | Gets / sets the image that the cell displays as background. (Default: NULL) |
BackgroundImageMode (GridBackgroundImageMode) | Indicates how the background image is displayed. (Default: GridBackgroundImageMode) |
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) | Static. (Default: TextBox) |
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) |
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 the cell should be skipped when moving the current cell. (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) |
FloatCell (System.Boolean) | Gets / sets if text can float into the boundaries of a neighboring cell. (Default: true) |
FloodCell (System.Boolean) | Gets / sets if this cell can be flooded by a previous cell. (Default: true) |
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 horizontal alignment of text 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. (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) |
MergeCell (GridMergeCellDirection) | Specifies merge behavior for an individual cell when merging cells feature has been enabled in a GridModel with MergeCellsMode. (Default: GridMergeCellDirection.None) |
ReadOnly (System.Boolean) | Specifies if cell contents can be modified by the user. You can programatically 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. (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 and the client rectangle of the cell without borders and cell buttons. (Default: GridMarginsInfo.Default) |
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 cell's style object. (Default: NULL) |
VerticalAlignment (GridVerticalAlignment) | Specifies vertical alignment of text 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
GridStaticCellRenderer(GridControlBase, GridCellModelBase)
Initializes a new instance of the GridStaticCellRenderer class for the given GridControlBase and GridCellModelBase.
Declaration
public GridStaticCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The GridControlBase that display this cell renderer. |
GridCellModelBase | cellModel | The GridCellModelBase that holds data for this cell renderer that should be shared among views. |
Remarks
References to GridControlBase, and GridCellModelBase will be saved.
Methods
CanCopy()
Allows single cell copy for static cells..
Declaration
public override bool CanCopy()
Returns
Type |
---|
System.Boolean |
Overrides
CanCut()
Allows single cell cut for static cells..
Declaration
public override bool CanCut()
Returns
Type |
---|
System.Boolean |
Overrides
DrawImage(Graphics, ImageList, Int32, Rectangle)
Draws an image at a given position in an ImageList onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle.
Declaration
[Obsolete("It is recommended to specify isRightToLeft parameter, default for isRightToLeft is False.")]
public static Rectangle DrawImage(Graphics g, ImageList imageList, int imageIndex, Rectangle bounds)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.Windows.Forms.ImageList | imageList | The image list. |
System.Int32 | imageIndex | The image index in the image list. |
System.Drawing.Rectangle | bounds | The target rectangle where the image should be drawn. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The bounds of the rectangle. Might differ if it was vertically centered. |
DrawImage(Graphics, ImageList, Int32, Rectangle, Boolean)
Draws an image at a given position in an ImageList onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle.
Declaration
public static Rectangle DrawImage(Graphics g, ImageList imageList, int imageIndex, Rectangle bounds, bool isRightToLeft)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.Windows.Forms.ImageList | imageList | The image list. |
System.Int32 | imageIndex | The image index in the image list. |
System.Drawing.Rectangle | bounds | The target rectangle where the image should be drawn. |
System.Boolean | isRightToLeft | Indicates if grid is in RightToLeft mode. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The bounds of the rectangle. Might differ if it was vertically centered. |
DrawImage(Graphics, ImageList, Int32, Rectangle, Rectangle, Boolean)
Draws an image at a given position in an ImageList onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle.
Declaration
public static Rectangle DrawImage(Graphics g, ImageList imageList, int imageIndex, Rectangle bounds, Rectangle clipBounds, bool isRightToLeft)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.Windows.Forms.ImageList | imageList | The image list. |
System.Int32 | imageIndex | The image index in the image list. |
System.Drawing.Rectangle | bounds | The target rectangle where the image should be drawn. |
System.Drawing.Rectangle | clipBounds | The target rectangle where the image should be clipped. |
System.Boolean | isRightToLeft | Indicates if grid is in RightToLeft mode. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The bounds of the rectangle. Might differ if it was vertically centered. |
DrawRotatedString(Graphics, String, Font, Brush, RectangleF, StringFormat, Single, GridStyleInfo)
Draws the text at the specified angle.
Declaration
public static void DrawRotatedString(Graphics g, string text, Font font, Brush br, RectangleF rect, StringFormat format, float angle, GridStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Graphical Parameter |
System.String | text | THe text to be rotated |
System.Drawing.Font | font | The font Style of the text |
System.Drawing.Brush | br | The brush used to draw the text |
System.Drawing.RectangleF | rect | The text rectangle |
System.Drawing.StringFormat | format | the format that holds different alignment settings |
System.Single | angle | The angle at which the text is rotated |
GridStyleInfo | style | Used to store all the information of the cell |
DrawText(Graphics, String, Font, Rectangle, GridStyleInfo, Color)
Draws a text at a given position onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle.
Declaration
[Obsolete("It is recommended to specify isRightToLeft parameter, default for isRightToLeft is False.")]
public static void DrawText(Graphics g, string displayText, Font font, Rectangle textRectangle, GridStyleInfo style, Color textColor)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.String | displayText | The display text. |
System.Drawing.Font | font | The font value. |
System.Drawing.Rectangle | textRectangle | The text rectangle. |
GridStyleInfo | style | Cell information with alignment, trimming, and HotkeyPrefix information. |
System.Drawing.Color | textColor | The text color. |
DrawText(Graphics, String, Font, Rectangle, GridStyleInfo, Color, Boolean)
Draws a text at a given position onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle.
Declaration
public static void DrawText(Graphics g, string displayText, Font font, Rectangle textRectangle, GridStyleInfo style, Color textColor, bool isRightToLeft)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.String | displayText | The display text. |
System.Drawing.Font | font | The font value. |
System.Drawing.Rectangle | textRectangle | The text rectangle. |
GridStyleInfo | style | Cell information with alignment, trimming, and HotkeyPrefix information. |
System.Drawing.Color | textColor | The text color. |
System.Boolean | isRightToLeft | Indicates if grid is in RightToLeft mode. |
DrawText(Graphics, String, Font, Rectangle, GridStyleInfo, Color, Boolean, Boolean)
Draws a text at a given position onto the System.Drawing.Graphics canvas at a specified System.Drawing.Rectangle and draws text optionally disabled.
Declaration
public static void DrawText(Graphics g, string displayText, Font font, Rectangle textRectangle, GridStyleInfo style, Color textColor, bool drawDisabled, bool isRightToLeft)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Points to the device context. |
System.String | displayText | The display text. |
System.Drawing.Font | font | The font value. |
System.Drawing.Rectangle | textRectangle | The text rectangle. |
GridStyleInfo | style | Cell information with alignment, trimming, and HotkeyPrefix information. |
System.Drawing.Color | textColor | The text color. |
System.Boolean | drawDisabled | True if text should be drawn disabled. |
System.Boolean | isRightToLeft | Indicates if grid is in RightToLeft mode. |
GetRotatedTextBound(String, Font, StringFormat, Single, Single)
Measures the Height and width of the text.
Declaration
public static RectangleF GetRotatedTextBound(string text, Font font, StringFormat format, float rotation, float dpiY)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The Input Text |
System.Drawing.Font | font | Font style of the Text |
System.Drawing.StringFormat | format | Alignment Settings of the text |
System.Single | rotation | The Angle of Rotation of the Text |
System.Single | dpiY | Vertical Resolution of the Text |
Returns
Type |
---|
System.Drawing.RectangleF |
IsPointOverImage(Int32, Int32, Point)
Checks if the specified point is over an image (see ImageIndex) .
Declaration
protected override bool IsPointOverImage(int rowIndex, int colIndex, Point pt)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Drawing.Point | pt | The point to be tested. |
Returns
Type | Description |
---|---|
System.Boolean | True if inside image; False otherwise. |
Overrides
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 | The GridStyleInfo object holds the style information of a cell. |
Overrides
RemoveMargins(Rectangle, GridStyleInfo)
Removes TextMargins from the specified client bounds.
Declaration
protected override Rectangle RemoveMargins(Rectangle clientRectangle, GridStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Rectangle | clientRectangle | The Rectangle |
GridStyleInfo | style | The GridStyleInfo object that holds cell information. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | A System.Drawing.Rectangle with the bounds. |