2016-10-05

‎Code

← Older revision

Revision as of 17:51, 5 October 2016

(3 intermediate revisions by the same user not shown)

Line 138:

Line 138:

== Mouse ==

== Mouse ==



Left
-click
on a data-cell always selects it and possibly opens editor (depends on options egoAlwaysShowEditor, egoReadOnly, ecoReadOnly and implementation of OnSelectEditor event).

+

;
Left
button

+

Click
on a data-cell always selects it and possibly opens editor (depends on options egoAlwaysShowEditor, egoReadOnly, ecoReadOnly and implementation of OnSelectEditor event).



Left-click
on a cell of fixed columns changes row, which in turn changes selection and possibly opens editor (see above).

+

Click
on a cell of fixed columns changes row, which in turn changes selection and possibly opens editor (see above).



Left-click
on a cell of fixed rows changes SortIndex if option ecoSorting of Column is set. It happens even if option egoSortArrow is not set (arrow is invisibe).

+

Click
on a cell of fixed rows changes SortIndex if option ecoSorting of Column is set. It happens even if option egoSortArrow is not set (arrow is invisibe).



Left-click on arrow-down area or right-click anywhere on the tab opens drop-down menu
.

+

; Middle button

+

Does nothing
.



Middle-click closes tab (if option etcoMiddleBtnClose is set
and
tab is closeable)
.

+

; Right button

+

Opens context menu. Note that Grid, Column
and
Column.Title can have different context menu
.



; Dragging

+

; Dragging
and Resizing



Dragging is realized by left mouse button
or middle mouse button
(
if option etcoMiddleBtnClose is NOT
set).

+

Dragging is realized by left mouse button
. Dragging moves column on the new position
(
egoColMoving must be
set)
. Fixed columns cannot be moved. Data columns cannot be moved in front of fixed columns. Shape of the mouse cursor shows if the column can be moved to the new position or not
.



When etcoFoldingPriority
is
NOT
set
:

+

Resizing
is
realized by left mouse button. Mouse must be pushed on the right edge of the column header (or the left edge in right-to-left BiDiMode) - when mouse cursor changes its shape.

+

Column width can be resized between MinWidth and MaxWidth. Both Options egoColSizing and ecoSizing must be
set
.



Dragging
moves
a tab
.

+

; Mouse Wheel

+

Wheel
moves
selection up/down
.



Dragging
+ CTRL key (exactly ssModifier)
folds a tab
.

+

Wheel
+ CTRL key (exactly ssModifier)
scrolls grid
.



Setting etcoFoldingPriority causes opposite
behaviour.

+

Option egoWheelScrollsGrid reverses this
behaviour.



+



Notes:

+



* etcoFixedPosition: tabs cannot be moved

+



* etoCanBeFolded: tab can be folded into another tab

+



* etoCanFold: tab can fold another tabs

+

== Keyboard ==

== Keyboard ==



Arrow keys change tab
(
only when
focused).

+

(
Grid must be
focused).



Arrow keys
+ CTRL key (exactly ssModifier) move tab (only when focused)
.

+

Arrow keys
change selection
.



Enter or Space opens drop-down menu of selected tab
(
only when focused
).

+

Arrow keys + CTRL key
(
exactly ssModifier
)
scroll grid
.



Acceleration
keys
(Alt + Key) change tab (doesn't need
to
be focused)
.

+

Home/End
keys
skip
to
the first/last data column
.



Note
to
multi-row tabs:
the row
with active tab is always placed on
the
baseline
.
Therefore, arrow
keys
Up and Down may sometime look like they work oppositely
(
assume horizontal position and active tab
is
NOT at
the first row).
It is by design
.

+

Home/End keys + CTRL key (exactly ssModifier) skip
to the
first/last data
row
.

+

+

PageUp/PageDown keys skip up/down by
the
number of visible rows
.

+

+

PageUp/PageDown
keys
+ CTRL key
(
exactly ssModifier) scroll up/down by the number of visible rows.

+

+

If option egoTabs
is
set, Tab key skips to the next data cell. If selection reaches the last column, it skips to
the first
column and the next
row
. Shift + Tab skips in  the opposite direction.

+

+

Enter, Space, F2, BackSpace and Delete keys open Editor (Grid/Column must not be egoReadOnly/ecoReadOnly
).

+

+

Keys 0..9 and A..Z also open Editor.

+

+

CTRL+C copies content of the selection to the clipboard
.

== Code ==

== Code ==

+

procedure BeginUpdate; override;

+

Reduces number of calculations and repaints when multiple properties change.

+

+

function CellRect(ACol, ARow: Integer): TRect;

+

Returns rectangle of the specified cell.

+

+

function CellRectEditor(ACol, ARow: Integer): TRect;

+

Returns corrected rectangle of the specified cell, it takes care of the GridLineWidth. Recommended for opening Editor.

+

+

procedure EndUpdate; override;

+

Each call of BeginUpdate; must be followed by EndUpdate. All changes will be processed.

+

+

function IsCellFullyVisible(ACol, ARow: Integer): Boolean;

+

Returns True if specified cell is fully visible.

+

+

function IsCellVisible(ACol, ARow: Integer): Boolean;

+

Returns True if specified cell is at least partially visible.

+

+

function IsColFullyVisible(ACol: Integer): Boolean;

+

Returns True if AColl is fully visible.

+

+

function IsColVisible(ACol: Integer): Boolean;

+

Returns True if ACol is at least partially visible.

+

+

function IsRowFullyVisible(ARow: Integer): Boolean;

+

Returns True if ARow is fully visible.

+

+

function IsRowVisible(ARow: Integer): Boolean;

+

Returns True if ARow is at least partially visible.

+

+

procedure LoadColumnsFromXML(AColumnsNode: TDOMNode; AXMLFlags: TXMLColFlags = cXMLColFlagsAll); overload;

+

procedure LoadColumnsFromXML(AFileName: string; AColumnsNode: DOMString; AXMLFlags: TXMLColFlags = cXMLColFlagsAll); overload;

+

Loads parameters of columns. Option egoUseOrder must be set for using the Order properties.

+

+

function MakeCellFullyVisible(ACol, ARow: Integer; AForceColVisible: Boolean): Boolean;

+

Makes specified cell visible (without selecting it). If column is invisible, it can be forced to show by AForce parameter.

+

+

procedure MouseToCell(AMouse: TPoint; out ACol, ARow: Integer);

+

Returns indexes of a cell placed on the coordinates AMouse.

+

+

procedure SaveColumnsToXML(AXMLDoc: TXMLDocument; AColumnsNode: TDOMNode; AXMLFlags: TXMLColFlags = cXMLColFlagsAll); overload;

+

procedure SaveColumnsToXML(AFileName: string; AColumnsNode: DOMString; AXMLFlags: TXMLColFlags = cXMLColFlagsAll); overload;

+

Saves parameters of columns.

+

+

procedure SaveToCSVFile(AFileName: string; ADelimiter: Char = ',';  AHeaders: Boolean = True; AVisibleColsOnly: Boolean = False);

+

Saves content of the grid to the text file.

+

+

procedure SelectCell(ACol, ARow: Integer; ASelectEditor: TEditorSelection; AForce: Boolean = False);

+

Changes selection to the cell specified by ACol and ARow. If column is invisible, it can be forced to show by AForce parameter. ASelectEditor specifies whether Editor will be opened (esNative depends on the egoAlwaysShowEditor).

+

+

procedure UpdateRows;

+

Call if you need to change number of data rows immediately. That's because RowCount is taken from OnGetDataRowCount event.

[[Category:Components]]

[[Category:Components]]

Show more