0

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.

Douglas Lise
  • 1,466
  • 1
  • 20
  • 46
  • Depending how you're implementing it, the TcxCustomGridRecord.Index may help? – Jason Jul 09 '13 at 03:07
  • No, unfortunately. I am scanning all records using a loop in GridA.DataController.RecordCount and using the method GetRowIndexByRecordIndex to obtain the row (that is different than record), thus I can call ViewInfo.RecordsViewInfo[iRow].ContentBounds. This works fine if I have no vertical scroll (few records). But if I start scrolling it doesn't find the lasts records. – Douglas Lise Jul 09 '13 at 11:16

1 Answers1

0

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;
Douglas Lise
  • 1,466
  • 1
  • 20
  • 46