by
ru
en
by

Avemey

logo
FilesMainLinksPhotosAnime

ZColorStringGrid component.
(inherited from TStringGrid)

Tested on Delphi 6-7, Borland Developer Studio 2005, BDS 2006, CodeGear Delphi 2007, CodeGear RAD Studio 2009 and 2010, XE and XE 2.
Also component works on C++ Builder 5-6.
Key features: Code samples.
See also ZCLabel - Label with rotating text and can draw on other canvas.

ZColorStringGrid sample screenshot ZColorStringGrid sample screenshot ZColorStringGrid sample screenshot
Screenshots

zip zcolorstringgrid_bin_0_4.zip (1495Kb) - Source code + compiled examples.
zip zcolorstringgrid_src_0_4.zip (462Kb) - Source code.

TZColorStringGrid

New properties:
Property Description
CellStyle[ACol, ARow: integer]: TCellStyle Set cell style
CellStyleCol[ACol: integer; fixedRow: boolean]: TCellStyle Set the style for the column
ACol - column number
fixedRow - when True, then also change for fixed cells in column
Write Only!
CellStyleRow[ARow: integer; fixedCol: boolean]: TCellStyle Set the style for the row
ARow - row number
fixedCol - when True, then also change for fixed cells in row
Write Only!
MergeCells: TMergeCells Merged cells
ZInplaceEditor: TZInplaceEditor Inplace cell editor
DefaultCellStyle: TCellStyle Style cell by default
DefaultFixedCellStyle: TCellStyle Style fixed cell by default
LineDesign: TLineDesign Color line.
SelectedColors: TSelectColor Color of the selected cells
SizingHeight: boolean when True, then increasing the height of the cell (when the text does not fit in the cell height)
SizingWidth: boolean when True, then increasing the width of the cell (when the text does not fit in the cell width)
UseCellSizingHeight: boolean when true - ignore SizingHeight, using cell style
UseCellSizingWidth: boolean when true - ignore SizingWidth, using cell style
UseCellWordWrap: boolean when true - ignore WordWrap, using cell style
WordWrap: boolean word wrap

New methods:
Method Description
procedure RowSelectYY(key: word); Highlights lines when goRowSelect in Options on merged cells.
Key - code of pressed key (VK_UP or VK_DOWN).

New events:
Event Description
OnBeforeTextDrawCell: TDrawCellEvent Event occurs before drawing the text in a cell
(If set SetBkMode (CellHandle, TRANSPARENT), then the text does not erase the background picture)
OnBeforeTextDrawMergeCell: TDrawMergeCellEvent Event occurs before drawing the text in a merged cell
OnDrawMergeCell: TDrawMergeCellEvent OnDrawCell for merged cells. Event occurs after drawing the text in a merged cell

TCellStyle

TCellStyle properties Description
BGColor: TColor The background color of the cell
BorderCellStyle: TBorderCellStyle Border style cell
Font: Tfont Font
HorizontalAlignment: TAlignment Alignment text horizontally
SizingHeight: boolean when True, then increasing the height of the cell (when the text does not fit in the cell height)
SizingWidth: boolean when True, then increasing the width of the cell (when the text does not fit in the cell width)
VerticalAlignment: TVerticalAlignment Alignment text vertically
Rotate: integer The angle of rotation of the text in cell. 0 by default.
IndentH: byte Horizontal indent. 2 by default.
IndentV: byte Vertical indent. 0 by default.
WordWrap: boolean Word wrap

TMergeCells

Style and the text in the merged cell is taken from the top left cell included in this area.

Properties:
TMergeCells properties Description
Count: integer Count of merged cells
Read Only!
Items[Num: Integer]: TRect Returns the coordinates of the merged cell of Num. (Left, Top) - the left top cell, (Right, Bottom) - the right bottom cell.
Num - number of merged cell.
Read Only!

Methods:
TMergeCells methods Description
function AddRect(Rct: TRect): byte; Adds a merged cell enclosed rectangle Rct.
Return:
  0 - The merged cell was added successfully
  1 - Specified merged cell outside the boundary grid
  2 - Specified merged cell overlaps (included) in the previously entered areas
  3 - Area of one cell does not add
  4 - Attempt to merge fixed and not fixed cells
function AddRectXY(x1, y1, x2, y2: integer): byte; Adds a merged cell enclosed rectangle (x1, y1, x2, y2). (x1, y1) - left top cell, (x2, y2) - right bottom cell.
Returns, too, that AddRect(Rct: TRect).
procedure Clear(); Removes all merged cells
function DeleteItem(num: integer): boolean; Delete merged cell num.
Return: True - the cell is deleted successfully.
function GetHeightArea(num: integer): integer; Return the height of merged cell num in the light of the lines between cells.
function GetWidthArea(num: integer): integer; Return the width of merged cell num in the light of the lines between cells.
function GetSelectedArea(SetSelected: boolean): TGridRect; Returns a rectangle with the selected cell takes into account the merged cells. Used to select multiple cells (shift + arrow keys).
SetSelected, if True - Selection receives the resulting rectangle
function InLeftTopCorner(ACol, ARow: integer): integer; Returns the number of merged cell, in which the cell [ACol, ARow] is top left. If returns a negative value - there is no such area.
function InMergeRange(ACol, ARow: integer): integer; Returns the number of merged cell that includes cell [ACol, ARow]. If returns a negative value - cell [ACol, ARow] is not contained in the Merge area.

TLineDesign

Properties:
TLineDesign properties Description
LineColor: TColor Color lines between cells
LineDownColor: TColor Color lines for not flat type cells - dark line.
Used when border style is sgLowered or sgRaised
LineUpColor: TColor Color lines for not flat type cells - light line.
Used when border style is sgLowered or sgRaised

TSelectColor

Properties:
TSelectColor properties Description
BGColor: TColor The background color of active (selected) cell
ColoredSelect: boolean If True, then use a color selection of the active (selected) cell
FontColor: TColor Font color in the selected cell
UseFocusRect: boolean If True, then the focused cell rectangle highlights

TDrawMergeCellEvent

type
  TDrawMergeCellEvent = procedure (Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState; var CellCanvas: TCanvas) of object;

CellCanvas
- Cell canvas.

TBorderCellStyle

type
  TBorderCellStyle = (sgLowered, sgRaised, sgNone);


sgLowered - like editor
sgRaised - like button
sgNone - without border

TVerticalAlignment

type
  TVerticalAlignment = (vaTop, vaCenter, vaBottom);


vaTop - text begin at the top edge of the cell
vaCenter - text is centered in the cell
vaBottom - text end at the bottom edge of the cell

FilesMainLinksPhotosAnime

Copyright © 2006-2012 Ruslan V. Neborak