On Wednesday 04 May 2016 00:37:16 Krzysztof wrote:
> Hi Martin,
>
> I'm lost with grids selections. How to make it work as simple
> TListView with "report" mode and "rowselect"? First of all, by default
> I don't see selection. So I checked this options:
>
>   gridAlbum.datacols.options := gridAlbum.datacols.options+
>     [co_fill,co_focusselect,co_mouseselect,co_rowselect];
>
We need to differ between focused cell and selected cells. By default focusing 
of a cell for example by clicking in it does not selecting it. co_rowselect 
selects the whole row if a cell has been selected by co_focusselect or 
co_mouseselect.

> Now I see what I selected. Going forward, real example from my app. I
> have two grids. By default no one is selected (I mean row). Selecting
> row in first grid, select first row in second grid (only if nothing
> selected in second grid). Same rule for second grid, selecting
> something select first row in first grid if nothing selected. Both
> grids have only one column. Runtime issues:
>
> 1. If nothing selected, grid.row() return value below 0 (for example
> -1073741823). Can I count on it? Should it be -1?

The coordinate system in MSEgui grids has its origin in the first datarow of 
the first datacolumn. Fixed rows and columns have negative indices:

   -2 -1 0 1 2 column-index
-2  F  F F F F
-1  F  F F F F
0   F  F D D D
1   F  F D D D
2   F  F D D D
|
+ row index

The big negative numbers mean "none" or "whole column/row", it is the number 
constant "invalidaxis" = "-bigint" = -"maxint div 2".

> 2. Tried with grid.getselectedrange.rowcount . If nothing selected
> then it return 0 which is correct. So if it is 0 then I'm selecting
> first row in second grid:
>
> procedure TLibraryWidget.ArtistSelected(const sender: tobject);
> begin
>   writeln('artist selected|',gridAlbum.getselectedrange.rowcount);
>   if gridAlbum.getselectedrange.rowcount=0 then
>     gridAlbum.selectcell(makegridcoord(0,0),csm_select);
> end;
>
> Problem is that, selectcell() indeed select row (I see it visually)
> but at runtime getselectedrange.rowcount is still 0 after selectcell()
> call so condition above is always TRUE. How to handle selections in
> grids properly?
>
Please use DataCols.HasSelection().
GetSelectedRange() returns information about the selection by user interaction 
with StartAnchor/EndAnchor which selects a rectangular area.

Martin

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to