【问题标题】:How to draw arrows to show linked data between records in two TcxGrid?如何绘制箭头以显示两个 TcxGrid 中记录之间的链接数据?
【发布时间】:2013-08-28 22:26:51
【问题描述】:

我的应用程序中有两个网格 (TcxGrid),每个网格位于表单的一侧。两个网格都显示链接数据,尽管它们可以单独垂直滚动。 我想在中间面板中绘制箭头,显示记录链接到的另一个网格的线,例如这个例子:

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

绘制过程很简单。我的麻烦在于确定记录位置。 考虑到可能在两个网格中进行分组,我如何发现每个网格行/记录的垂直位置?

提前谢谢你。

【问题讨论】:

  • 根据您的实施方式,TcxCustomGridRecord.Index 可能会有所帮助?
  • 不,很遗憾。我正在使用 GridA.DataController.RecordCount 中的循环扫描所有记录,并使用 GetRowIndexByRecordIndex 方法获取行(不同于记录),因此我可以调用 ViewInfo.RecordsViewInfo[iRow].ContentBounds。如果我没有垂直滚动(很少记录),这很好用。但是如果我开始滚动它就找不到最后的记录。

标签: delphi devexpress tcxgrid devexpress-windows-ui


【解决方案1】:

我发现可以通过这种方式获得网格记录的垂直位置:

网格视图具有属性ViewData.RowsRows 是一个数组,它的每个元素都有 RecordIndex 属性。因此,您可以遍历Rows 数组并测试它的RecordIndex 是否是您要查找的那个,如果为真,则获取属性ViewInfo.ClientBounds.Top

例子:

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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 1970-01-01
    相关资源
    最近更新 更多