Skip to main content

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.

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

NameTypeDescriptionValue
COL_NOCHANGEInt32Leaves the corresponding color unchanged in color setters.
COL_NOT_BGInt32Legacy sentinel indicating no background color.
ROWDELETE_BMPInt32Legacy bitmap identifier for a deleted row.
ROWEDIT_BMPInt32Legacy bitmap identifier for an edited row.
ROWNEW_BMPInt32Legacy bitmap identifier for a newly inserted row.
TBL_BMP_BESTFITInt32Scales a bitmap proportionally to fit its display region.
TBL_BMP_BOTTOMInt32Aligns the bitmap at the bottom edge when the top flag is absent.
TBL_BMP_CENTERInt32Centers the bitmap horizontally when no left or right flag is supplied.
TBL_BMP_COLORInt32Keeps the bitmap in color; this is the zero-valued default.
TBL_BMP_LEFTInt32Aligns the bitmap at the left edge.
TBL_BMP_MONOInt32Requests grayscale conversion when adding a bitmap.
TBL_BMP_RIGHTInt32Aligns the bitmap at the right edge when the left flag is absent.
TBL_BMP_SCALEInt32Uses the default bitmap alignment without requesting scaling.
TBL_BMP_TOFITInt32Stretches a bitmap to fill its display region.
TBL_BMP_TOPInt32Aligns the bitmap at the top edge.
TBL_BMP_VCENTERInt32Centers the bitmap vertically when no top or bottom flag is supplied.
TBL_FLG_BOLDInt32Enables bold when modifying a font style.
TBL_FLG_DOTTEDCOLLINESInt32Zero-valued legacy default for dotted column lines.
TBL_FLG_DOTTEDROWLINESInt32Zero-valued legacy default for dotted row lines.
TBL_FLG_ITALICInt32Enables italic when modifying a font style.
TBL_FLG_NOBOLDInt32Removes bold; takes precedence over the enable flag.
TBL_FLG_NOCOLLINESInt32Identifies the legacy option to hide column lines.
TBL_FLG_NOCOLORSInt32Identifies the legacy option to suppress custom colors.
TBL_FLG_NOFONTSInt32Identifies the legacy option to suppress custom fonts.
TBL_FLG_NOITALICInt32Removes italic; takes precedence over the enable flag.
TBL_FLG_NOROWLINESInt32Identifies the legacy option to hide row lines.
TBL_FLG_NOSTRIKEOUTInt32Removes strikeout; takes precedence over the enable flag.
TBL_FLG_NOUNDERLINEInt32Removes underline; takes precedence over the enable flag.
TBL_FLG_SOLIDCOLLINESUInt32Identifies the legacy option for solid column lines.
TBL_FLG_SOLIDROWLINESInt32Identifies the legacy option for solid row lines.
TBL_FLG_STRIKEOUTInt32Enables strikeout when modifying a font style.
TBL_FLG_UNDERLINEInt32Enables underline when modifying a font style.

Methods

Static member AddBitmap(table, hBitmap, nFlags, nWidth, nHeight, nTransparentColor, nInversionColor, nIndex)

Registers a bitmap and its alignment in the table image list.

ParameterTypeDescription
tableControlThe SAL table control.
hBitmapSalNumberThe nonzero native bitmap handle to copy.
nFlagsSalNumberThe TBL_BMP grayscale, alignment, and scaling flags.
nWidthSalNumberReserved for compatibility; ignored.
nHeightSalNumberReserved for compatibility; ignored.
nTransparentColorSalNumberThe color to make transparent, or COL_NOCHANGE to preserve transparency.
nInversionColorSalNumberReserved for compatibility; ignored.
nIndexSalNumberThe 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);
}
}
}

Static member AddRowBitmap(table, hBitmap, nFlags, nWidth, nHeight, nTransparentColor, nInversionColor, nRowFlags, nIndex, bReplace)

Reports that row-header bitmap registration is not implemented.

ParameterTypeDescription
tableControlRequested table; ignored.
hBitmapSalNumberRequested bitmap handle; ignored.
nFlagsSalNumberRequested bitmap flags; ignored.
nWidthSalNumberRequested width; ignored.
nHeightSalNumberRequested height; ignored.
nTransparentColorSalNumberRequested transparent color; ignored.
nInversionColorSalNumberRequested inversion color; ignored.
nRowFlagsSalNumberRequested row flags; ignored.
nIndexSalNumberRequested bitmap index; ignored.
bReplaceSalBooleanRequested replacement behavior; ignored.

Returns: SalNumber. Always zero.

Static member FreeBitmap(hBitmap)

Releases a native bitmap handle.

ParameterTypeDescription
hBitmapSalNumberThe handle to pass to DeleteObject.

Returns: SalBoolean. False for a zero handle; otherwise, the native DeleteObject result.

Static member GetCellBitmap(table, nRow, nCol)

Gets the registered bitmap index assigned to the cell.

ParameterTypeDescription
tableControlThe SAL table control.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier.

Returns: SalNumber. The stored index, or -1 when the table/style is unavailable or no indexed image map is defined.

Static member GetCellColor(table, nRow, nCol, nForeColor, nBackColor)

Gets the cell color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColor by referenceSalNumberReceives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails.
nBackColor by referenceSalNumberReceives 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.

Static member GetCellFont(table, nRow, nCol)

Gets the cell font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.

Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.

Static member GetColBitmap(table, nCol)

Gets the registered bitmap index assigned to the column.

ParameterTypeDescription
tableControlThe SAL table control.
nColSalNumberThe SAL column identifier.

Returns: SalNumber. The stored index, or -1 when the table/style is unavailable or no indexed image map is defined.

Static member GetColColor(table, nCol, nForeColor, nBackColor)

Gets the column color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColor by referenceSalNumberReceives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails.
nBackColor by referenceSalNumberReceives 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.

Static member GetColFont(table, nCol)

Gets the column font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.

Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.

Static member GetColHdrColor(table, nCol, nForeColor, nBackColor)

Gets the column header color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColor by referenceSalNumberReceives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails.
nBackColor by referenceSalNumberReceives 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.

Static member GetColHdrFont(table, nCol)

Gets the column header font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.

Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.

Static member GetRowColor(table, nRow, nForeColor, nBackColor)

Gets the row color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nForeColor by referenceSalNumberReceives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails.
nBackColor by referenceSalNumberReceives 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.

Static member GetRowFont(table, nRow)

Gets the row font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.

Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.

Static member GetRowHdrColor(table, nRow, nForeColor, nBackColor)

Gets the row header color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nForeColor by referenceSalNumberReceives the Win32 foreground color, or COLOR_Default when the style does not define it; unchanged if lookup fails.
nBackColor by referenceSalNumberReceives 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.

Static member GetRowHdrFont(table, nRow)

Gets the row header font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.

Returns: SalNumber. The TBL_FLG font-style bits, or zero when the table, style, or font is unavailable.

Static member GetTableFont(table)

Gets the table font style.

ParameterTypeDescription
tableControlThe 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.

Static member LoadBitmap(sFileName)

Loads an image file and creates a native bitmap handle.

ParameterTypeDescription
sFileNameSalStringThe 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.

Static member RemoveBitmap(table, nIndex)

Accepts a removal request for a registered bitmap.

ParameterTypeDescription
tableControlThe table control.
nIndexSalNumberThe 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.

Static member RemoveRowBitmap(table, nIndex)

Reports that row-header bitmap removal is not implemented.

ParameterTypeDescription
tableControlRequested table; ignored.
nIndexSalNumberRequested bitmap index; ignored.

Returns: SalBoolean. Always false.

Static member Reset(table)

Clears row and column font and color overrides in the main grid.

ParameterTypeDescription
tableControlThe 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.

Static member SetCellBitmap(table, nRow, nCol, nIndex)

Assigns a registered bitmap to the cell style.

ParameterTypeDescription
tableControlThe SAL table control.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier.
nIndexSalNumberThe registered image index.

Returns: SalBoolean. True on success; false for an unavailable table/style or an invalid image index.

Static member SetCellColor(table, nRow, nCol, nForeColor, nBackColor)

Changes the cell color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColorSalNumberThe SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override.
nBackColorSalNumberThe 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);
}
}

Static member SetCellFont(table, nRow, nCol, nFlags)

Changes the cell font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nFlagsSalNumberThe 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.

Static member SetColBitmap(table, nCol, nIndex)

Assigns a registered bitmap to the column style.

ParameterTypeDescription
tableControlThe SAL table control.
nColSalNumberThe SAL column identifier.
nIndexSalNumberThe 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.

Static member SetColColor(table, nCol, nForeColor, nBackColor)

Changes the column color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColorSalNumberThe SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override.
nBackColorSalNumberThe 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.

Static member SetColFont(table, nCol, nFlags)

Changes the column font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nFlagsSalNumberThe 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.

Static member SetColHdrColor(table, nCol, nForeColor, nBackColor)

Changes the column header color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nForeColorSalNumberThe SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override.
nBackColorSalNumberThe 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.

Static member SetColHdrFont(table, nCol, nFlags)

Changes the column header font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nColSalNumberThe SAL column identifier, resolved through GetColumnFromId.
nFlagsSalNumberThe 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.

Static member SetRowColor(table, nRow, nForeColor, nBackColor)

Changes the row color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nForeColorSalNumberThe SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override.
nBackColorSalNumberThe 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.

Static member SetRowFont(table, nRow, nFlags)

Changes the row font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nFlagsSalNumberThe 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.

Static member SetRowHdrColor(table, nRow, nForeColor, nBackColor)

Changes the row header color values.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nForeColorSalNumberThe SAL foreground color; COL_NOCHANGE preserves it, while COLOR_Default or null clears the override.
nBackColorSalNumberThe 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.

Static member SetRowHdrFont(table, nRow, nFlags)

Changes the row header font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nRowSalNumberThe SAL row index.
nFlagsSalNumberThe 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.

Static member SetTableFont(table, nFlags)

Changes the table font style.

ParameterTypeDescription
tableControlThe SAL table control or a control that resolves to one.
nFlagsSalNumberThe 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.