DataGridViewCell
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.1.0.0)
Represents an individual cell in a DataGridView control.
- C#
- VB.NET
public class DataGridViewCell : DataGridViewElement, ICloneable, ICommandSource, IUserData
Public Class DataGridViewCell
Inherits DataGridViewElement
Implements ICloneable, ICommandSource, IUserData
Constructors
DataGridViewCell()
Initializes a new instance of DataGridViewCell.
Properties
CellRenderer
String: Returns the name of the cell renderer to use on the client side to render the cell. If it's null or empty, it defaults to "Cell".
The name of the cell renderer can be a fully qualified class name (i.e. "wisej.web.datagrid.cellRenderer.Cell") or just the class name (i.e. "ImageCell") in which case the client library prepends "wisej.web.datagrid.cellRenderer".
ClientColIndex
Int32: Returns the column index on the client, accounting to the header column.
Value: The index of he column that contains the cell; -1 if there is no owning column.
ClientRowIndex
Int32: Returns the row index on the client, accounting for hidden rows.
Value: The index of the row that contains the cell; -1 if there is no owning row.
ColumnIndex
Int32: Returns the column index for this cell.
Value: The index of the column that contains the cell; -1 if the cell is not contained within a column.
Command
ICommand: Returns or sets the ICommand implementation to invoke. (Default: null)
ContextMenu
ContextMenu: Returns or sets the shortcut menu associated with the cell. (Default: null)
Value: The ContextMenu associated with the cell.
Control
Control: Returns or sets a child control to display inside the cell.
DataGridView
DataGridView: Returns the DataGridView control associated with this DataGridViewCell.
Value: A DataGridView control that contains this element. The default is null.
DefaultNewRowValue
Object: Returns the default value for a cell in the row for new records.
Value: An Object representing the default value.
Displayed
Boolean: Returns a value that indicates whether the cell is currently displayed.
Value: true if the cell is on-screen or partially on-screen; otherwise, false.
Editable
Boolean: Returns whether the cell can be edited.
EditedFormattedValue
Object: Returns the current, formatted value of the cell, regardless of whether the cell is in edit mode and the value has not been committed.
Value: The current, formatted value of the DataGridViewCell.
Throws:
- ArgumentOutOfRangeException The row containing the cell is a shared row; or the cell is a column header cell.
- InvalidOperationException ColumnIndex is less than 0, indicating that the cell is a row header cell.
- Exception Formatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. The exception object can typically be cast to type FormatException.
EditType
Type: Returns the type of the cell's hosted editing control.
Value: A Type representing the control used to edit the cell content.
ErrorText
String: Returns or sets the text describing an error condition associated with the cell.
Value: The text that describes an error condition associated with the cell.
FormattedValue
Object: Returns the value of the cell as formatted for display.
Value: The formatted value of the cell or null if the cell does not belong to a DataGridView control.
Throws:
- InvalidOperationException ColumnIndex is less than 0, indicating that the cell is a row header cell.
- ArgumentOutOfRangeException The row containing the cell is a shared row; or the cell is a column header cell.
- Exception Formatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. The exception object can typically be cast to type FormatException.
FormattedValueType
Type: Returns the type of the formatted value associated with the cell.
Value: A Type representing the type of the cell's formatted value.
FormattedValueTypeConverter
TypeConverter: Returns the type converter to use to convert a formatted value to the cell's value type.
Frozen
Boolean: Returns a value indicating whether the cell is frozen.
Value: true if the cell is frozen; otherwise, false.
HasStyle
Boolean: Returns true it the Style property has been set.
Value: true if the Style property has been set; otherwise, false.
HasUserData
Boolean: Checks if the UserData dynamic object was created and has any value.
Height
Int32: Returns the height of the cell.
InheritedState
DataGridViewElementStates: Returns the current state of the cell as inherited from the state of its row and column.
Value: A combination of DataGridViewElementStates values representing the current state of the cell.
Throws:
- ArgumentException The cell is not contained within a DataGridView control and the value of its RowIndex property is not -1.
- ArgumentOutOfRangeException The cell is contained within a DataGridView control and the value of its RowIndex property is -1.
InheritedStyle
DataGridViewCellStyle: Returns the style currently applied to the cell.
Value: The DataGridViewCellStyle currently applied to the cell.
Throws:
- InvalidOperationException The cell does not belong to a DataGridView control; or ColumnIndex is less than 0, indicating that the cell is a row header cell.
- ArgumentOutOfRangeException The row containing the cell is a shared row; or the cell is a column header cell.
IsCurrentCell
Boolean: Returns whether this is the current cell in the DataGridView.
Value: true if the cell is the same as CurrentCell.
IsInEditMode
Boolean: Returns a value indicating whether this cell is currently being edited.
Value: true if the cell is in edit mode; otherwise, false.
OwningColumn
DataGridViewColumn: Returns the column that contains this cell.
Value: The DataGridViewColumn that contains the cell, or null if the cell is not in a column.
OwningRow
DataGridViewRow: Returns the row that contains this cell.
Value: The DataGridViewRow that contains the cell, or null if the cell is not in a row.
ReadOnly
Boolean: Returns or sets whether the cell's data can be edited.
Value: true if the cell's data cannot be edited; otherwise, false.
Resizable
Boolean: Returns a value indicating whether the cell can be resized.
Value: true if the cell can be resized; otherwise, false.
RowIndex
Int32: Returns the index of the cell's parent row.
Value: The index of the row that contains the cell; -1 if there is no owning row.
Selected
Boolean: Returns or sets whether the cell has been selected.
Value: true if the cell has been selected; otherwise, false.
Size
Size: Returns the size of the cell.
Value: A Size set to the owning row's height and the owning column's width.
Style
DataGridViewCellStyle: Returns or sets the style for the cell.
Value: A DataGridViewCellStyle.
Tag
Object: Returns or sets the object that contains supplemental data about the cell. (Default: null)
Value: An Object that contains data about the cell. The default is null.
ToolTipText
String: Returns or sets the ToolTip text associated with this cell.
Value: The ToolTip text associated with the cell. The default is Empty.
UserData
Object: Returns a dynamic object that can be used to store custom data in relation to this cell.
UserPaint
Boolean: Enables or disables the user paint feature for this cell. When UserPaint is true, the application can handle the CellPaint event to draw custom content in the cell. (Default: False)
Value
Object: Returns or sets the value associated with this cell.
Value: Gets or sets the data to be displayed by the cell. The default is null.
Throws:
- ArgumentOutOfRangeException RowIndex is outside the valid range of 0 to the number of rows in the control minus 1.
- InvalidOperationException ColumnIndex is less than 0, indicating that the cell is a row header cell.
ValueType
Type: Returns or sets the data type of the values in the cell.
Value: A Type representing the data type of the value in the cell.
ValueTypeConverter
TypeConverter: Return the type converter to use to convert the value in the cell to the formatted value.
Visible
Boolean: Returns a value indicating whether the cell is in a row or column that has been hidden.
Value: true if the cell is visible; otherwise, false.
Width
Int32: Returns the width of the cell.
Methods
Clone()
Creates a copy of this cell.
Returns: DataGridViewCell. The cloned DataGridViewCell.
CompareValue(newValue, oldValue)
Compares the new value being assigned to the cell with the previous value.
| Parameter | Type | Description |
|---|---|---|
| newValue | Object | New value being assigned to the cell. |
| oldValue | Object | Current value assigned to the cell being replaced by newValue |
Returns: Boolean. true if newValue and oldValue are different.
CreateEditingControl()
Creates a new instance of the edit control used to edit values in this cell.
Returns: Control.
Dispose(disposing)
Releases the resources used by the DataGridViewCell.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | true when this method is called by the application rather than a finalizer. |
GetCellDataValue(cellStyle, includeVisualProperties)
Returns the data value of the cell. This is the value that is returned to the client in the data response stream.
| Parameter | Type | Description |
|---|---|---|
| cellStyle | DataGridViewCellStyle | The cell style in effect for the current cell, used to format the cell's value for the client rendering. |
| includeVisualProperties | Boolean | true to include inherited visual properties; otherwise, false to include only formatting properties. |
Returns: Object.
GetClipboardContent(rowIndex, firstCell, lastCell, inFirstRow, inLastRow, format)
Returns the formatted value of the cell to copy to the Clipboard.
| Parameter | Type | Description |
|---|---|---|
| rowIndex | Int32 | The zero-based index of the row containing the cell. |
| firstCell | Boolean | true to indicate that the cell is in the first column of the region defined by the selected cells; otherwise, false. |
| lastCell | Boolean | true to indicate that the cell is the last column of the region defined by the selected cells; otherwise, false. |
| inFirstRow | Boolean | true to indicate that the cell is in the first row of the region defined by the selected cells; otherwise, false. |
| inLastRow | Boolean | true to indicate that the cell is in the last row of the region defined by the selected cells; otherwise, false. |
| format | String | The current format string of the cell. |
Returns: Object. An Object that represents the value of the cell to copy to the Clipboard.
Throws:
- ArgumentOutOfRangeException rowIndex is less than 0 or greater than or equal to the number of rows in the control.
- InvalidOperationException The value of the cell's DataGridView property is null.-or-ColumnIndex is less than 0, indicating that the cell is a row header cell.
- Exception Formatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. The exception object can typically be cast to type FormatException.
GetCommand()
Returns the command bound to the cell.
Returns: ICommand. The value contained in the DataGridViewCell.
GetEditedFormattedValue()
Returns the current, formatted value of the cell, regardless the cell being in edit mode.
Returns: Object. The current, formatted value of the DataGridViewCell.
Throws:
- Exception Formatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. The exception object can typically be cast to type FormatException.
GetErrorText()
Returns a string that represents the error for the cell.
Returns: String. A string that describes the error for the current DataGridViewCell.
GetFormattedValue(value, cellStyle, valueTypeConverter, formattedTypeConverter)
Returns the value of the cell formatted for the client.
| Parameter | Type | Description |
|---|---|---|
| value | Object | The value to be formatted. |
| cellStyle | DataGridViewCellStyle | The DataGridViewCellStyle in for the cell. |
| valueTypeConverter | TypeConverter | A TypeConverter providing custom conversion from the formatted type to the value type, or null if no custom conversion is required. |
| formattedTypeConverter | TypeConverter | A TypeConverter providing custom conversion from the value type to the formatted type, or null if no custom conversion is required. |
Returns: Object. The value of the cell or null if the cell does not belong to a DataGridView control.
Throws:
- Exception Formatting failed and there is no handler for the DataError event of the DataGridView or the handler set the ThrowException property to true.
GetInheritedContextMenu()
Returns the inherited ContextMenu for the current cell.
Returns: ContextMenu. A ContextMenu instance if the DataGridViewCell, or the owner DataGridViewRow, or the owner DataGridViewColumn, or the owner DataGridView has a ContextMenu assigned; otherwise, null.
GetInheritedState()
Returns a value indicating the current state of the cell as inherited from the state of its row and column.
Returns: DataGridViewElementStates. A combination of DataGridViewElementStates values representing the current state of the cell.
GetInheritedStyle(includeVisualProperties)
Returns the style applied to the cell.
| Parameter | Type | Description |
|---|---|---|
| includeVisualProperties | Boolean | true to include inherited visual properties; otherwise, false to include only formatting properties. |
Returns: DataGridViewCellStyle. A DataGridViewCellStyle that includes the style settings of the cell inherited from the cell's parent row, column, and DataGridView.
Throws:
- InvalidOperationException The cell has no associated DataGridView.
GetToolTipText()
Returns a string that represents the tooltip text for the cell.
Returns: String. A string that describes the tooltip text for the current DataGridViewCell.
GetValue()
Returns the value of the cell.
Returns: Object. The value contained in the DataGridViewCell.
InitializeEditingControl(editor, style)
Initializes the control used to edit the cell.
| Parameter | Type | Description |
|---|---|---|
| editor | Control | The Control that is used to edit the cell. |
| style | DataGridViewCellStyle | The DataGridViewCellStyle that is in effect for the cell entering edit mode. |
Throws:
- ArgumentNullException editor is null.
OnCellFormatting(e)
Raised when the contents of a cell need to be formatted for display.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellFormattingEventArgs | A DataGridViewCellFormattingEventArgs that contains the event data. |
OnClick(e)
Raised when the user clicks on a cell.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellEventArgs | A DataGridViewCellEventArgs that contains the event data. |
OnDataGridViewChanged()
Called when the element is associated with a different DataGridView.
OnDoubleClick(e)
Raised when the user double-clicks on a cell.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellEventArgs | A DataGridViewCellEventArgs that contains the event data. |
OnEnter(e)
Raised when the cell becomes the active cell.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellEventArgs | A DataGridViewCellEventArgs that contains the event data. |
OnKeyDown(e)
Raised when the user types on the keyboard while the grid has the focus and it's not in edit more.
| Parameter | Type | Description |
|---|---|---|
| e | KeyEventArgs | A KeyEventArgs that contains the event data. |
OnLeave(e)
Raised when the cell is not the active cell anymore.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellEventArgs | A DataGridViewCellEventArgs that contains the event data. |
OnMouseClick(e)
Raised when the user clicks or taps on a cell.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellMouseEventArgs | A DataGridViewCellMouseEventArgs that contains the event data. |
OnMouseDoubleClick(e)
Raised when the user double-clicks or double-taps on a cell.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellMouseEventArgs | A DataGridViewCellMouseEventArgs that contains the event data. |
ParseFormattedValue(value, cellStyle, formattedTypeConverter, valueTypeConverter)
Converts a value to the actual cell value.
| Parameter | Type | Description |
|---|---|---|
| value | Object | The display value of the cell. |
| cellStyle | DataGridViewCellStyle | The DataGridViewCellStyle in effect for the cell. |
| formattedTypeConverter | TypeConverter | A TypeConverter for the display value type, or null to use the default converter. |
| valueTypeConverter | TypeConverter | A TypeConverter for the cell value type, or null to use the default converter. |
Returns: Object. The cell value.
Throws:
- ArgumentNullException cellStyle is null.
- FormatException The FormattedValueType property value is null or the ValueType property value is null or value cannot be converted.
- ArgumentException value is null or the type of value does not match the type indicated by the FormattedValueType property.
RaiseCellCommandChanged(e)
Fires the CellCommandChanged event.
| Parameter | Type | Description |
|---|---|---|
| e | DataGridViewCellEventArgs | A DataGridViewCellEventArgs that contains the event data. |
ResetReadOnly()
Resets the ReadOnly state to inherit its value from the OwningColumn, OwningRowand the DataGridView.
SetCommand(command)
Sets the command for the cell.
| Parameter | Type | Description |
|---|---|---|
| command | ICommand | The cell command to set. |
Returns: Boolean. True if the value has been set, otherwise false.
SetValue(value)
Sets the value of the cell.
| Parameter | Type | Description |
|---|---|---|
| value | Object | The cell value to set. |
Returns: Boolean. True if the value has been set, otherwise false.
ShouldUpdate() 3.2.5+
Indicates whether the cell data should be updated on the client even if the user didn't change the value when editing.
Returns: Boolean. true to force the cell to update the client.
Used to allow the server to update the cell after editing mode is terminated and the user didn't change anything. For example, a password cell can be obfuscated, or a custom cell may need to always format the rendered value when terminating edit mode.
Update()
Updates the cell on the client.
Inherited By
| Name | Description |
|---|---|
| DataGridViewButtonCell | Displays a button widget in a DataGridViewCell cell. |
| DataGridViewCheckBoxCell | Displays a CheckBox icon (not the actual control) in a DataGridViewCell cell. |
| DataGridViewComboBoxCell | Displays an editable ComboBox control in a DataGridViewCell cell when in edit mode. |
| DataGridViewDateTimePickerCell | Displays an editable DateTimePicker control in a DataGridViewCell cell when in edit mode. |
| DataGridViewImageCell | Displays an image in a DataGridViewCell cell. |
| DataGridViewLinkCell | Displays a link widget in a DataGridViewCell cell. |
| DataGridViewMaskedTextBoxCell | Displays an editable MaskedTextBox control in a DataGridViewCell cell when in edit mode. |
| DataGridViewNumericUpDownCell | Displays an editable NumericUpDown control in a DataGridViewCell cell when in edit mode. |
| DataGridViewTextBoxCell | Displays an editable TextBox control in a DataGridViewCell cell when in edit mode. |
| DataGridViewColumnHeaderCell | Represents a column header in a DataGridView control. |
| DataGridViewHeaderCell | Contains functionality common to row header cells and column header cells. |
| DataGridViewRowHeaderCell | Represents a row header of a DataGridView control. |
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| ICommandSource | Defines an object that can invoke a Command. |