VisTblEx
Namespace: PPJ.Runtime.Vis
Assembly: PPJ.Runtime.Vis.50 (5.0.0.0)
Provides table color, font, and bitmap extensions for WinForms SAL table controls.
- C#
- VB.NET
public class VisTblEx
Public Class VisTblEx
Example:
void Highlight(System.Windows.Forms.Control table, PPJ.Runtime.SalNumber row)
{
PPJ.Runtime.Vis.VisTblEx.SetRowColor(table, row,
PPJ.Runtime.Sys.COLOR_Red, PPJ.Runtime.Sys.COLOR_Default);
}
Fields
| Name | Type | Description | Value |
|---|---|---|---|
| COL_NOCHANGE | Int32 | Leaves the corresponding color unchanged in color setters. | |
| COL_NOT_BG | Int32 | Legacy sentinel indicating no background color. | |
| ROWDELETE_BMP | Int32 | Legacy bitmap identifier for a deleted row. | |
| ROWEDIT_BMP | Int32 | Legacy bitmap identifier for an edited row. | |
| ROWNEW_BMP | Int32 | Legacy bitmap identifier for a newly inserted row. | |
| TBL_BMP_BESTFIT | Int32 | Scales a bitmap proportionally to fit its display region. | |
| TBL_BMP_BOTTOM | Int32 | Aligns the bitmap at the bottom edge when the top flag is absent. | |
| TBL_BMP_CENTER | Int32 | Centers the bitmap horizontally when no left or right flag is supplied. | |
| TBL_BMP_COLOR | Int32 | Keeps the bitmap in color; this is the zero-valued default. | |
| TBL_BMP_LEFT | Int32 | Aligns the bitmap at the left edge. | |
| TBL_BMP_MONO | Int32 | Requests grayscale conversion when adding a bitmap. | |
| TBL_BMP_RIGHT | Int32 | Aligns the bitmap at the right edge when the left flag is absent. | |
| TBL_BMP_SCALE | Int32 | Uses the default bitmap alignment without requesting scaling. | |
| TBL_BMP_TOFIT | Int32 | Stretches a bitmap to fill its display region. | |
| TBL_BMP_TOP | Int32 | Aligns the bitmap at the top edge. | |
| TBL_BMP_VCENTER | Int32 | Centers the bitmap vertically when no top or bottom flag is supplied. | |
| TBL_FLG_BOLD | Int32 | Enables bold when modifying a font style. | |
| TBL_FLG_DOTTEDCOLLINES | Int32 | Zero-valued legacy default for dotted column lines. | |
| TBL_FLG_DOTTEDROWLINES | Int32 | Zero-valued legacy default for dotted row lines. | |
| TBL_FLG_ITALIC | Int32 | Enables italic when modifying a font style. | |
| TBL_FLG_NOBOLD | Int32 | Removes bold; takes precedence over the enable flag. | |
| TBL_FLG_NOCOLLINES | Int32 | Identifies the legacy option to hide column lines. | |
| TBL_FLG_NOCOLORS | Int32 | Identifies the legacy option to suppress custom colors. | |
| TBL_FLG_NOFONTS | Int32 | Identifies the legacy option to suppress custom fonts. | |
| TBL_FLG_NOITALIC | Int32 | Removes italic; takes precedence over the enable flag. | |
| TBL_FLG_NOROWLINES | Int32 | Identifies the legacy option to hide row lines. | |
| TBL_FLG_NOSTRIKEOUT | Int32 | Removes strikeout; takes precedence over the enable flag. | |
| TBL_FLG_NOUNDERLINE | Int32 | Removes underline; takes precedence over the enable flag. | |
| TBL_FLG_SOLIDCOLLINES | UInt32 | Identifies the legacy option for solid column lines. | |
| TBL_FLG_SOLIDROWLINES | Int32 | Identifies the legacy option for solid row lines. | |
| TBL_FLG_STRIKEOUT | Int32 | Enables strikeout when modifying a font style. | |
| TBL_FLG_UNDERLINE | Int32 | Enables underline when modifying a font style. |
Methods
AddBitmap(table, hBitmap, nFlags, nWidth, nHeight, nTransparentColor, nInversionColor, nIndex)
Registers a bitmap and its alignment in the table image list.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
| hBitmap | SalNumber | The nonzero native bitmap handle to copy. |
| nFlags | SalNumber | The TBL_BMP grayscale, alignment, and scaling flags. |
| nWidth | SalNumber | Reserved for compatibility; ignored. |
| nHeight | SalNumber | Reserved for compatibility; ignored. |
| nTransparentColor | SalNumber | The color to make transparent, or COL_NOCHANGE to preserve transparency. |
| nInversionColor | SalNumber | Reserved for compatibility; ignored. |
| nIndex | SalNumber | The insertion index; -1 or the current image count appends. |
Returns: SalNumber. The registered image index, or -1 for an unresolved table, a zero bitmap handle, or an invalid insertion index.
TBL_BMP_TOFIT takes precedence over TBL_BMP_BESTFIT. The registered bitmap is a copy; the caller retains ownership of the native handle.
Example:
Register a bitmap copy and assign its returned index to an existing cell. The source native handle is released even when registration or assignment fails.
using System.Drawing;
using PPJ.Runtime;
using PPJ.Runtime.Vis;
using PPJ.Runtime.Windows;
using System.Runtime.InteropServices;
public static class TableBadge
{
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(System.IntPtr handle);
public static bool Assign(SalTableWindow table, SalNumber row,
SalNumber columnId, Bitmap badge)
{
System.IntPtr handle = badge.GetHbitmap();
try
{
SalNumber index = VisTblEx.AddBitmap(table, handle,
VisTblEx.TBL_BMP_BESTFIT, 0, 0,
VisTblEx.COL_NOCHANGE, VisTblEx.COL_NOCHANGE, -1);
if (index < 0)
return false;
return VisTblEx.SetCellBitmap(table, row, columnId, index);
}
finally
{
// AddBitmap copied the image; release our native handle.
DeleteObject(handle);
}
}
}
AddRowBitmap(table, hBitmap, nFlags, nWidth, nHeight, nTransparentColor, nInversionColor, nRowFlags, nIndex, bReplace)
Reports that row-header bitmap registration is not implemented.
| Parameter | Type | Description |
|---|---|---|
| table | Control | Requested table; ignored. |
| hBitmap | SalNumber | Requested bitmap handle; ignored. |
| nFlags | SalNumber | Requested bitmap flags; ignored. |
| nWidth | SalNumber | Requested width; ignored. |
| nHeight | SalNumber | Requested height; ignored. |
| nTransparentColor | SalNumber | Requested transparent color; ignored. |
| nInversionColor | SalNumber | Requested inversion color; ignored. |
| nRowFlags | SalNumber | Requested row flags; ignored. |
| nIndex | SalNumber | Requested bitmap index; ignored. |
| bReplace | SalBoolean | Requested replacement behavior; ignored. |
Returns: SalNumber. Always zero.
FreeBitmap(hBitmap)
Releases a native bitmap handle.
| Parameter | Type | Description |
|---|---|---|
| hBitmap | SalNumber | The handle to pass to DeleteObject. |
Returns: SalBoolean. False for a zero handle; otherwise, the native DeleteObject result.
GetCellBitmap(table, nRow, nCol)
Gets the registered bitmap index assigned to the cell.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier. |
Returns: SalNumber. The stored index, or -1 when the table/style is unavailable or no indexed image map is defined.
GetCellColor(table, nRow, nCol, nForeColor, nBackColor)
Gets the cell color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | Receives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
| nBackColor | SalNumber | Receives the Win32 background color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
GetCellFont(table, nRow, nCol)
Gets the cell font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
GetColBitmap(table, nCol)
Gets the registered bitmap index assigned to the column.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
| nCol | SalNumber | The SAL column identifier. |
Returns: SalNumber. The stored index, or -1 when the table/style is unavailable or no indexed image map is defined.
GetColColor(table, nCol, nForeColor, nBackColor)
Gets the column color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | Receives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
| nBackColor | SalNumber | Receives the Win32 background color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
GetColFont(table, nCol)
Gets the column font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
GetColHdrColor(table, nCol, nForeColor, nBackColor)
Gets the column header color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | Receives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
| nBackColor | SalNumber | Receives the Win32 background color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
GetColHdrFont(table, nCol)
Gets the column header font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
GetRowColor(table, nRow, nForeColor, nBackColor)
Gets the row color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nForeColor | SalNumber | Receives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
| nBackColor | SalNumber | Receives the Win32 background color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
GetRowFont(table, nRow)
Gets the row font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
GetRowHdrColor(table, nRow, nForeColor, nBackColor)
Gets the row header color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nForeColor | SalNumber | Receives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
| nBackColor | SalNumber | Receives the Win32 background color, or COLOR_Default when the style does not define it; unchanged if lookup fails. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
GetRowHdrFont(table, nRow)
Gets the row header font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
GetTableFont(table)
Gets the table font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.
LoadBitmap(sFileName)
Loads an image file and creates a native bitmap handle.
| Parameter | Type | Description |
|---|---|---|
| sFileName | SalString | The image file path. |
Returns: SalNumber. The native bitmap handle, or zero when the file is not found.
The caller must release a returned handle with FreeBitmap. Other loading or conversion errors propagate.
RemoveBitmap(table, nIndex)
Accepts a removal request for a registered bitmap.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The table control. |
| nIndex | SalNumber | The zero-based bitmap index to validate. |
Returns: SalBoolean. False if the table or index is invalid; otherwise true.
The implementation calls ArrayList.Remove with the numeric argument rather than RemoveAt. Registered ImageInfo entries therefore remain in the collection.
RemoveRowBitmap(table, nIndex)
Reports that row-header bitmap removal is not implemented.
| Parameter | Type | Description |
|---|---|---|
| table | Control | Requested table; ignored. |
| nIndex | SalNumber | Requested bitmap index; ignored. |
Returns: SalBoolean. Always false.
Reset(table)
Clears row and column font and color overrides in the main grid.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
Returns: SalBoolean. True when the table resolves; otherwise, false.
Clears unused styles afterward. This is not a full table-data reset and does not explicitly clear every cell style or registered bitmap.
SetCellBitmap(table, nRow, nCol, nIndex)
Assigns a registered bitmap to the cell style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier. |
| nIndex | SalNumber | The registered image index. |
Returns: SalBoolean. True on success; false for an unavailable table/style or an invalid image index.
SetCellColor(table, nRow, nCol, nForeColor, nBackColor)
Changes the cell color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | The SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
| nBackColor | SalNumber | The SAL background color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Invalidates the table after updating the style.
Example:
Highlight an existing cell without changing its foreground, then clear only the background override. Pass a column identifier, not its display position.
using PPJ.Runtime;
using PPJ.Runtime.Vis;
using PPJ.Runtime.Windows;
public static class CellHighlight
{
public static bool Apply(SalTableWindow table, SalNumber row, SalNumber columnId)
{
return VisTblEx.SetCellColor(table, row, columnId,
VisTblEx.COL_NOCHANGE, Sys.COLOR_Yellow);
}
public static bool Reset(SalTableWindow table, SalNumber row, SalNumber columnId)
{
return VisTblEx.SetCellColor(table, row, columnId,
VisTblEx.COL_NOCHANGE, Sys.COLOR_Default);
}
}
SetCellFont(table, nRow, nCol, nFlags)
Changes the cell font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
A Regular result clears the local font override; other styles use the table font family and size.
SetColBitmap(table, nCol, nIndex)
Assigns a registered bitmap to the column style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control. |
| nCol | SalNumber | The SAL column identifier. |
| nIndex | SalNumber | The registered image index. |
Returns: SalBoolean. True after assigning the image map; false when the table or column style is unavailable.
Unlike SetCellBitmap, this method does not validate the image index before reading its alignment.
SetColColor(table, nCol, nForeColor, nBackColor)
Changes the column color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | The SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
| nBackColor | SalNumber | The SAL background color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Invalidates the table after updating the style.
SetColFont(table, nCol, nFlags)
Changes the column font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
A Regular result clears the local font override; other styles use the table font family and size.
SetColHdrColor(table, nCol, nForeColor, nBackColor)
Changes the column header color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nForeColor | SalNumber | The SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
| nBackColor | SalNumber | The SAL background color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Invalidates the table after updating the style.
SetColHdrFont(table, nCol, nFlags)
Changes the column header font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nCol | SalNumber | The SAL column identifier, resolved through GetColumnFromId. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
A Regular result clears the local font override; other styles use the table font family and size.
SetRowColor(table, nRow, nForeColor, nBackColor)
Changes the row color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nForeColor | SalNumber | The SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
| nBackColor | SalNumber | The SAL background color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Invalidates the table after updating the style.
SetRowFont(table, nRow, nFlags)
Changes the row font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
A Regular result clears the local font override; other styles use the table font family and size.
SetRowHdrColor(table, nRow, nForeColor, nBackColor)
Changes the row header color values.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nForeColor | SalNumber | The SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
| nBackColor | SalNumber | The SAL background color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Invalidates the table after updating the style.
SetRowHdrFont(table, nRow, nFlags)
Changes the row header font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nRow | SalNumber | The SAL row index. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
A Regular result clears the local font override; other styles use the table font family and size.
SetTableFont(table, nFlags)
Changes the table font style.
| Parameter | Type | Description |
|---|---|---|
| table | Control | The SAL table control or a control that resolves to one. |
| nFlags | SalNumber | The TBL_FLG font enable/disable bits; disable bits take precedence when both are present. |
Returns: SalBoolean. True when the table and target style are available; otherwise, false.
Preserves font family and size while changing style bits.