1

我正在编辑 TVirtualStringTree 中显示节点的第二列。但是,编辑完成后,我无法使用 Sender.GetNodeData(Node) 检索文本 - 它不包含任何文本。

如何获取 OnEdited 事件中的文本?还有其他方法可以获取编辑后的文本吗?我已经阅读了 Virtual Treeview CHM 帮助文档的前几个常见问题页面,并且还参考了这个 SO question中的答案,但找不到答案。

这是当前代码:

  TTherapData = record
    TherapID: Integer;
    TherapName: String[120];
    TherapInstr: String[120];
    Selected: Byte;
  end;

  PTherapData = ^TTherapData;

procedure TfmPatient_Conslt.vstRxList_AsgEdited(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
var
  TherapData: PTherapData;
begin
  TherapData := Sender.GetNodeData(Node);
  if Assigned(TherapData) then
  begin
    TherapData^.TherapInstr := vstRxList_Asg.Text[Node, 1];
    showmessage(TherapData^.TherapInstr);
  end;

  FTherapDataListAsg_Iter := 0;
  vstRxList_Asg.NodeDataSize := SizeOf(TTherapData);
  vstRxList_Asg.RootNodeCount := 0;
  vstRxList_Asg.RootNodeCount := TherapDataList_CountSelectedItems;

end;
4

1 回答 1

1

感谢TLama的提示,答案是处理OnNewText事件:

procedure TfmPatient_Conslt.vstRxList_AsgNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
  NewText: string);
var
  TherapData: PTherapData;
begin

  if (Column = 1) then
  begin
    TherapData := Sender.GetNodeData(Node);
    if Assigned(TherapData) then
      TherapData^.TherapInstr := NewText;
  end;

end;
于 2014-11-03T14:54:38.450 回答