MultiRow Windows Forms > Developer's Guide > Using MultiRow > Cell Types > ButtonCell |
The button cell offers features equivalent to the Button control of the .NET Framework (System.Windows.Forms.Button). The user can use the button cell to execute a command by clicking. The size of the button is automatically adjusted according to the cell size.
In addition to the Base Cell features, the following features can also be used in a button cell.
For more details on each feature, refer to the ButtonCell class.
The button cell uses the value Object type and this type can be checked with the ButtonCell.ValueType property. The caption displayed on the button uses a value that has been type cast to a String type. This type can be checked by the ButtonCell.FormattedValueType property. You can modify the behavior when type casting by overriding the ToString method of the Object type. Override the ButtonCell.OnCellFormatting method to change behavior when a value is read into the cell. Then override the ButtonCell.OnCellParsing method to change behavior when the value is written back from the cell.
The button cell does not provide a cell edit control. The ButtonCell.EditType property always returns a null reference (Nothing in Visual Basic).
The button cell supports the following members of the CellStyle class. You can set cell styles by using the ButtonCell.Style property.
CellStyle Members | Enabled or Disabled |
BackColor | Enabled |
Border | Enabled |
DataSourceNullValue | Enabled |
DisabledBackColor | Enabled |
DisabledForeColor | Enabled |
Font | Enabled |
ForeColor | Enabled |
Format | Enabled |
FormatProvider | Enabled |
Image | Enabled |
ImageAlign | Enabled |
ImeMode | - |
ImeSentenceMode | - |
LineAdjustment | Enabled only for GDI+Compatible Mode |
Margin | Enabled |
Multiline | Enabled |
NullValue | Enabled |
Padding | Enabled |
PatternColor | Enabled |
PatternStyle | Enabled |
SelectionBackColor | Enabled |
SelectionForeColor | Enabled |
Tag | Enabled |
TextAdjustment | Enabled only for GDI+Compatible Mode |
TextAlign | Enabled |
TextAngle | Enabled only for GDI+Compatible Mode |
TextEffect | Enabled |
TextImageRelation | Enabled |
TextIndent | Enabled |
TextVertical | Enabled only for GDI+Compatible Mode |
UseCompatibleTextRendering | Enabled |
WordWrap | Enabled |
To enable GDI+ Compatible Mode, set the UseCompatibleTextRendering property to True.
In a button cell, Keys.Space is allocated for the button click. The rest of the keys are processed by the GcMultiRow control.
You can use the GcMultiRow.CellContentClick event to implement processing for any click in the cell content area. In case of a double-click, you can use the GcMultiRow.CellContentDoubleClick event.
This table shows comparisons between the main properties of ButtonCell, System.Windows.Forms.Button control, and System.Windows.Forms.DataGridViewButtonCell.
ButtonCell | Button | DataGridViewButtonCell |
Ellipsis | AutoEllipsis | None |
None | AutoSize | None |
Style.BackColor | BackColor | Style.BackColor |
FlatStyle | FlatStyle | FlatStyle |
FlatAppearance | FlatAppearance | None |
Style.ForeColor | ForeColor | Style.ForeColor |
None | None | UseColumnTextForButtonValue |
Style.Image | Image | None |
None | ImageIndex | None |
None | ImageKey | None |
None | ImageList | None |
Style.ImageAlign | ImageAlign | None |
Style.ImeMode | ImeMode | None |
Value | Text | Value |
Style.TextAlign | TextAlign | Style.Alignment |
Style.TextImageRelation | TextImageRelation | None |
None | UseCompatibleTextRendering | None |
None | UseMnemonic | None |
UseVisualStyleBackColor | UseVisualStyleBackColor | None |
For more information, see the following topics: