在VirtualTreeView节点上重新绘制选择有问题。当我在运行时更改节点文本并重新绘制树或实际聚焦的节点选择框架时,不会更新。
下面是测试应用程序的屏幕(XE3,VT版本= 5.2.0)



我该如何解决这个问题?
我尝试过RepaintNode, Repaint, Paint (来自VirtualTreeView的方法),但没有成功。我知道我可以改变VT的来源,但是如果没有必要的话,我不会这么做
在我的测试应用程序下面。谢谢!
DFM:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 461
ClientWidth = 822
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object vt1: TVirtualStringTree
Left = 296
Top = 72
Width = 273
Height = 217
Header.AutoSizeIndex = 0
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.MainColumn = -1
RootNodeCount = 20
TabOrder = 0
OnGetText = vt1GetText
Columns = <>
end
object edt1: TEdit
Left = 336
Top = 24
Width = 121
Height = 21
TabOrder = 1
Text = 'edt1'
end
object btn1: TButton
Left = 360
Top = 312
Width = 75
Height = 25
Caption = 'btn1'
TabOrder = 2
OnClick = btn1Click
end
end考绩制度:
type
TForm1 = class(TForm)
vt1: TVirtualStringTree;
edt1: TEdit;
btn1: TButton;
procedure vt1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
[..]
procedure TForm1.btn1Click(Sender: TObject);
begin
vt1.RepaintNode(vt1.GetFirst);
end;
procedure TForm1.vt1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
begin
CellText := edt1.Text;
end;发布于 2020-04-23 10:21:01
为了结束这个问题,并将其标记为“已解决”,我将写@TLama的评论作为回答:
使用
InvalidateNode。
https://stackoverflow.com/questions/24199584
复制相似问题