我在VirtualTreeView节点上重绘选择有问题。当我在运行时更改节点文本并重新绘制树或实际聚焦节点时 - 选择框架未更新。
来自测试应用程序(XE3,VT Version = 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
PAS:
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;
答案 0 :(得分:0)
所以可以关闭该问题并将其标记为已解决,我将以@TLama的评论作为答案:
使用
InvalidateNode
。