Question

I have two grids (TcxGrid) in my application, each one in a side of the form. Both grids show linked data, although they could be scrolled vertically separatedly. I want to draw arrows in the middle panel, showing the line of the other grid that the record is linked to, like this example:

GridA   GridB
+---+   +---+
| a |---| a |
| b |   | i |
| c |\  | h |
| d | \ | g |
| e |  \| h |
| f |   | b |
+---+   +---+

The draw proccess are simple. My trouble is with identify the record positions. How do I discover what is the vertical position of each grid row/record, considering that could have grouping in both grids?

Thank you in advance.

Was it helpful?

Solution

I've discovered that the vertical position of a grid's record can be obtained in this way:

The grid view has the property ViewData.Rows. Rows is an array and each element of it has the RecordIndex property. So you can iterate over the Rows array and test if its RecordIndex is which the one you are finding and, if true, get the property ViewInfo.ClientBounds.Top.

Example:

for i := 0 to gdMovimentoTV.ViewData.RowCount - 1 do 
  if gdMovimentoTV.ViewData.Rows[i].RecordIndex = iSomeRecordIndex then begin
    if Assigned(gdMovimentoTV.ViewData.Rows[i].ViewInfo) then begin
      Result := gdMovimentoTV.ViewData.Rows[i].ViewInfo.ClientBounds.Top;
      Break;
    end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top