AdvStringGrid documentation (v1.40)
© by TMS software
Procedures - Properties - Events - Info
- Delphi page
Procedures
procedure ClearRows(RowIndex, RCount: LongInt);
Description : clears contents of all cells starting from row RowIndex to
RowIndex+Rcount-1.
procedure RemoveRows(RowIndex, RCount: LongInt);
Description : removes all rows from the stringgrid, starting from row
RowIndex to row RowIndex+RCount-1.
procedure InsertRows(RowIndex, RCount: LongInt);
Description : inserts Rcount empty rows after row position RowIndex.
procedure RemoveCols(ColIndex, CCount: LongInt);
Description : removes all columns from the
stringgrid, starting from column ColIndex to column ColIndex+CCount-1.
procedure InsertCols(ColIndex, CCount: LongInt);
Description : inserts Ccount empty columns after
column position ColIndex.
procedure SwapColumns(aCol1,aCol2:longint);
Description : swaps contents of all cells of column
1 and column 2.
procedure MoveColumn(FromIndex,ToIndex:longint);
Description : move contents of all cells of column
FromIndex to column ToIndex.
procedure MoveRow(FromIndex,ToIndex:longint);
Description : move contents of all cells of row
FromIndex to row ToIndex.
procedure HideColumn(ColIndex::longint);
Description : hide display of column=colindex.
procedure UnhideColumn(ColIndex:longint);
Description : shows a hidden column=colindex again..
procedure IsHiddenColumn(ColIndex:longint):boolean;
Description : returns true if column=colindex is
hidden..
procedure SwapRows(aRow1,aRow2:longint);
Description : swaps contents of all cells of row 1 and row 2.
procedure Clear;
Description : clears contenst of all cells of the
stringgrid. No cells are removed, only content is cleared.
function Findfirst(s: String; findparams: TFindParams):tpoint;
Description : searches the stringgrid for text s,
with options for search in findparams. This set is defineed as :
TFindParameters = (fnMatchCase,fnMatchFull,fnMatchRegular).
TFindParams = set of TFindParameters;
FindFirst returns col/row of first cell matching the search specification. If no
cell is found, the returned cell is (-1,-1)
function FindNext : tpoint;
Description : continues the search in the grid for
text initiated by FindFirst.
procedure LoadFromFile(FileName: String);
Description : loads contents as well as size of the
stringgrid from a ASCII file previously created by calling the SaveToFile routine.
procedure LoadFromFile(FileName: String);
Description : loads contents as well as size of the
stringgrid from a ASCII file previously created by calling the SaveToFile routine.
procedure SaveToFile(FileName: String);
Description : saves contents as well
as size of the stringgrid to a ASCII file so it can be restored later by calling the
LoadFromFile routine.
procedure LoadFromStream(Stream: TStream);
Description : loads contents as well as size of the
stringgrid from a generic stream. For example, a filestream can be used to save contents
to file or a memorystream to copy data from one stringgrid to another stringgrid.
procedure SaveToStream(Stream: TStream);
Description : saves contents as well
as size of the stringgrid to a generic stream.
procedure SaveToHTML(FileName: String);
Description : saves contents of
stringgrid as well as aligments in HTML format.
procedure SaveToCSV(FileName: String);
Description : saves contents of
stringgrid to a comma delimited text file.
procedure LoadFromCSV(FileName: String);
Description : loads contents of
stringgrid from a comma delimited text file.
procedure CutToClipboard;
Description : copies contents of
stringgrid to the clipboard and clears all cells.
procedure CopyToClipBoard;
Description : copies contents of stringgrid to the
clipboard.
procedure CopySelectionToClipboard;
Description : copies contents of selected cells to
the clipboard.
procedure PasteFromClipboard;
Description : pastes data from clipboard into cells.
procedure PasteSelectionFromClipboard;
Description : pastes data from clipboard into cells
at current selected cell at position row,col.
procedure LoadFromXLS(Filename:string);
Description : only for Delphi
2 or Delphi 3 ! Uses OLE automation to transfer cell contents from XLS file with
name Filename, loaded into Excel.
procedure SavetoXLS(Filename:string);
Description : only for Delphi
2 or Delphi 3 ! Uses OLE automation to transfer cell contents to Excel and save to
XLS file with name Filename.
procedure AutoSizeCol(const ACol: LongInt);
Description : modifies the size of column ACol so
that all text properly fits in the column.
procedure AutoNumberCol(const ACol:longint);
Description : simple autonumbering of cells in a
column starting from 1 in first non-fixed row.
procedure QSort;
Description : performs a complete quicksort of the
stringgrid, starting from the column indicated by the SortColumn property.
procudure Print;
Description : prints the entire stringgrid to the
selected printer, using the printer setting properties of TAdvStringGrid.
procedure PrintRect(gridrect:tgridrect);
Description : prints only the cells in gridrect to
the selected printer, using the printer setting properties of TAdvStringGrid.
procedure PrintPreview(canvas:tcanvas);
Description : shows a preview of the printout with
exactly the same printer setting properties in the selected canvas.
procedure PrintPreviewRect(canvas:tcanvas;gridrect:tgridrect);
Description : shows a preview of the printout with
exactly the same printer setting properties in the selected canvas for the cells in
gridrect.
procedure SortByColumn(col:integer);
Description : sort the column col and set SortColumn
property to col.
procedure QuickSort(col,left,right:integer);
Description : perform a quicksort of all cells from
row left to row right for a given column col.
procedure Search(s:string):longint;
Description : return the first cell containing the string s, or partially
matching string s.
procedure
AddImageIdx(Acol,Arow,aIdx:integer;hal:TCellHalign;val;TCellValign);
Description : only for Delphi
2 or Delphi 3 : adds an image idx from the imagelist assigned to GridImages to cell
Acol,Arow with
alignment defined by hal and val.
hal = (haLeft,haCenter,haRight,haBeforeText,haAfterText)
val = (vaTop,vaCenter,vaBottom,vaAboveText,vaUnderText)
procedure RemoveImageIdx(Acol,Arow:integer);
Description : only for Delphi
2 or Delphi 3 : removes the image from cell aCol, Arow. Note
: it is not necessary to remove the image
at the cell, before adding a new image, since AddImageIdx automatically cleans up
previously assigned images.
procedure
AddBitmap(Acol,Arow:integer;Abitmap:tBitmap;transparent:boolean;hal:TCellHalign;val;TCellValign);
Description : adds a bitmap to
cell Acol,Arow with alignment defined by hal and val. The transparent parameter
controls display the bitmap transparently. Transparency color is determined by the pixel
in the upper left corner of
the bitmap.
procedure RemoveBitmap(Acol,Arow:integer);
Description : removes the
bitmap in cell Acol,Arow
procedure
AddIcon(Acol,Arow,aIdx:integer;hal:TCellHalign;val;TCellValign);
Description : adds an icon to
cell Acol,Aro with alignment defined by hal and val.
procedure RemoveIcon(Acol,Arow:integer);
Description : removes the icon
in cell Acol,Arow
procedure Zoom(nr:integer);
Description : zoom in or out
on stringgrid
property Ints[ACol,ARow:Integer]:integer;
Description : property to access the cells as
integers. Exception is raised when cell does not contain integer data and read is
performed.
property Dates[ACol,ARow:Integer]:tdatetime;
Description : property to access the cells as
TDateTime values. Exception is raised when cell does not contain a valid date string.
property AutoSize:boolean;
Description : setting the Autosize property to true,
resizes all columns to widths so that all text just fits.
property EnhTextSize:boolean;
Description : If true, text in cells is appended
with ... if it doesn't fit into the cell.
property EnableGraphics:boolean;
Description : If false, users can store
non-objects to string Objects[] property.
property SizeWithForm:boolean;
Description : If true, the stringgrid resizes itself
when the parent form also resizes.
property Multilinecells:boolean;
Description : If true, multiline cells are
supported. Multiline text can be entered in cells by using the #13 line separator. For
example : 'this is a'#13'multiline text' will be displayed as two lines when enabled.
Warning : the line separator might change to #10 in future versions.
property SortColumn:integer;
Description : When the SortColumn property is set, the specified column is
sorted. Can also be used to readback which column the user has clicked to sort.
property SortShow: boolean;
Description : If true, sorting when clicking on
column headers is enabled and the triangle sort indicators are displayed in the column
headers.
property SortFixedCols: boolean;
Description : If true, sorts fixed columns too when
clicked.
property SortDirection:TSortDirection;
Description : Sets direction of sort globally for
stringgrid.
TSortDirection = (sdAscending,sdDescending);
property HintColor:tcolor;
Description : Sets the color of the hints appearing
in the stringgrid. This does not modify color of hints on other components on the same
form.
property PrintSettings:TPrintSettings;
Description : Property to hold all printout settings
:
property Time: TPrintPosition; : sets position on page of time of printout.
property Date: TPrintPosition; : sets position on page of date of printout
property PageNr: TPrintPosition; : sets position on page of page number
property Title: TPrintPosition; : sets position of title of printout
property TitleText : string; : sets title of printout
property Font: TFont; : sets font of printout
property Borders : TPrintBorders; : sets drawing method of borders for printout
property Centered : boolean; : if true, printout is centered on the page.
property RepeatHeaders : boolean; : if true, printout header is repeated on each page.
property FooterSize : integer : controls distance to skip at start of page in units of
1/10mm.
property HeaderSize : integer : controls distance to skip at end of page in units of
1/10mm.
property LeftSize : integer : controls distance to skip at left side of page in units of
1/10mm.
property RightSize : integer : controls distance to skip at right side of page in units of
1/10mm.
property ColumnSpacing : integer : controls distance to skip between 2 columns in units of
1/10mm.
property Orientation : TPrinterOrientation : sets printer orientation to landscape or
portrait
property PagePrefix : string : sets the prefix for page numbering for printout
property FixedHeight : height of rows for printout in 0.1mm
property FixedWidth : width of columns for printout in 0.1mm
property UseFixedHeight : if enabled, uses value FixedHeight, else auto calculation is
done
property UseFixedWidth : if enabled, uses value FixedWidth, else auto calculation is done
with
TPrintPosition =
(ppNone,ppTopLeft,ppTopRight,ppTopCenter,ppBottomLeft,ppBottomRight,ppBottomCenter);
TPrintBorders = (pbNoBorder,pbSingle,pbDouble);
TPrintOrientation = (poLandscape,poPortrait)
property Navigation:TNavigation;
Description : property to hold all settings of
enhanced keyboard navigation in the grid
property AllowInsertRow:boolean; : INS key will insert row if true
property AllowDeleteRow:boolean; : DEL key will delete row if true
property AdvanceOnEnter:boolean; : next cell is selected after pressing enter while
editing current cell
property AdvanceInsert : if true, allows insertion of rows when last cell is entered when
in AdvanceOnEnter mode
property AllowClipboardShortCuts:boolean; : if true, enables Ctrl-Ins, Shift Ins, Ctrl-Del
keys or also Ctrl-V, Ctrl-X, Ctrl-C to perform clipboard actions
AutoGotoWhenSorted : if true, allows jumping to rows with single keypress in sorted
column.
property ColumnSize:TColumnSize;
Description : property to hold settings for saving
column sizes.
property Save:boolean; : if true, column sizes are saved into registry or INI file.
property Key:string; : key in INI file or registry where sizes are stored
property Section:string; : section in INI file or registry where sizes are stored
property Stretch:boolean; : automatic stretching of rightmost column to full grid size
Note : for Delphi 2 & 3 registry is used, for Delphi 1, INI files are used.
property FixedFooters:integer;
Description : property to set
number of fixed rows at bottom side of the grid
property FixedRightcols:integer;
Description : property to set
number of fixed columns at right side of the grid
property GridImages:TImageList;
Description : property to set imagelist from which
bitmaps are taken to display when using SetImageIdx / RemoveImageIdx functions.
property Delimiter:char;
Description : public only property to set delimiter
character to use for functions SaveToCSV / LoadFromCSV, defaults to comma.
property HintShowCells:boolean; only for Delphi 3
Description : hints are full cell contents.
property ScrollProportional:boolean;
Description : enable proportional scrollbars.
property SizeWhileTyping:boolean;
Description : enables column sizing (vertical and/or
horizontal) while typing text.
Events
property OnGetCellColor: TGridColorEvent;
Description : event handler called to set the color
of a cell. If no handler is specified or your handler simply return, default color
settings are used.
TGridColorEvent = procedure (Sender: TObject; ARow, ACol: Longint; AState:
TGridDrawState; ABrush: TBrush; AFont: TFont ) of object;
ARow and Acol indicate cell for which color must be set. ABrush specifies the cell
background brush. AFont can be used to modify font for a given cell.
property OnGetCellPrintColor: TGridColorEvent;
Description : identical as OnGetCellColor, but for
printing. Can be same event handler as OnGetCellColor or a separate event handler if
needed.
property OnGetAlignment: TGridAlignEvent;
Description : event handler called to set alignment
of a cell. If no handler is specified or your handler simply returns, left alignment is
used.
TGridAlignEvent = procedure (Sender: TObject; ARow, ACol: Longint; var AAlignment:
TAlignment) of object;
TAlignment can be taLeftJustify, taRightJustify or taCenter.
property OnGetFormat: TGridFormatEvent;
Description : event handler called to set datatype
of cells in a column. This is called during sorts to determine method for sorting. Sorting
can be alphabetic, numeric or using dates.
TGridFormatEvent = procedure (Sender : TObject; ACol:longint;var AStyle:TSortStyle) of
object;
TSortStyle can be ssAutomatic, ssAlphabetic, ssNumeric, ssDate, ssAlphaCase,
ssAlphaNoCase, ssShortDateEU, ssShortDateUS.
property OnGridHint:TGridHintEvent;
Description : event handler can be used to set
different hints for each cell. Set the hintstring parameter for a given column and row to
specify a special hint for a given cell. Default StringGrid hint is used when no handler
is defined or handler simply return.
TGridHintEvent = procedure (Sender:TObject; Arow, Acol:longint; var hintstr:string) of
object;
property OnAutoInsertRow:TAutoInsertRowEvent;
Description : event handler called after
user has inserted a row by pressing INS button. Can be used to initialize a row to default
data.
TAutoInsertRowEvent = procedure(Sender:TObject; ARow:longint) of object;
property OnAutoDeleteRow:TAutoDeleteRowEvent;
Description : event handler called after
user has deleted a row by pressing DEL button.
TAutoDeleteRowEvent = procedure(Sender:TObject; aRow:longint) of object;
property OnClickSort:TClickSortEvent;
Description : event handler called when user clicked
on the fixed column header to sort on a specific column.
TClickSortEvent = procedure(Sender:TObject; aCol:longint) of object;
property OnCanSort:TCanSortEvent;
Description : event handler called when user clicked
on a column header to sort a column. The event handler is called before starting the sort
to query if the column can be sorted. If no handler is specified or handler simply
returns, sorting is performed, otherwise, set dosort to false to disable sorting a
specific column.
TCanSortEvent = procedure(Sender:TObject; aCol:longint; var dosort:boolean) of object;
property OnPrintPage:TGridPrintPageEvent;
Description : event handler called when a page is
printed (either on hardcopy or during printpreview). This event handler creates the
possibility to add custom drawing to the printing process. The Canvas is passed as a
parameter and can be used to draw. Notice that changing canvas settings such as pen, font,
brush affect printing other data. If a setting like a font must be changed for the custom
printing process, the original settings must be restored. This can be done in following
way for a font for example :
savefont:=tfont.create;
savefont.assign(font);
//do custom drawing here and change font
font.assign(savefont);
savefont.free;
Printing is done in a canvas set to MM_LOMETRIC. This means that all units are in 1/10mm and page coordinates go from 0,0 to xsize,-ysize. There are no restrictions to the position where custom drawing is done.
property OnClickCell :TClickCellEvent;
Description : event handler called when left mouse
is pressed on a cell which returns column and row of the selected cell.
TClickCellEvent = procedure (Sender:TObject;Arow,Acol:longint) of object;
property OnDblClickCell :TDblClickCellEvent;
Description : event handler called when left mouse
is dubbleclicked on a cell which returns column and row of the selected cell.
TDblClickCellEvent = procedure (Sender:TObject;Arow,Acol:longint) of object;
property OnCanEditCell :TCanEditCellEvent;
Description : event handler to set a cell to
read-only.
TCanEditCellEvent = procedure (Sender:TObject;Arow,Acol:longint;var canedit:boolean) of
object;
Set canedit to false if the cell Arow,Acol must be readonly.
property OnCellValidate :TCellValidateEvent;
Description : event handler to add posibility to do
input validation. The event handler is called after the user leaves a cell after editing.
Set the Valid parameter to false is input is not accepted and cell should contain old
value.
TCellValidateEvent = procedure(Sender: TObject; Col, Row: Longint; var Value: String; var
Valid: Boolean) of object;
TAdvStringGrid is now released as v1.33. We want to thank all existing users for their
input, either reporting problems or giving usefull suggestions of enhancements. We look
forward to hear your inputs to enhance the component even more.
TAdvStringGrid is free for use in non-commercial applications, that is applications which
are not being sold in any form. Source code and license are available for $50.
Payment for now is only possible by sending a check, cash, postal order or bank
transaction to :
TMS software
J. Jordaens str 11
B8510 Marke
fax: +32/56 359696
email : tms@theLinx.com