【发布时间】:2014-06-13 07:09:02
【问题描述】:
我在 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;
【问题讨论】:
-
使用
InvalidateNode。 -
@TLama 完美!非常感谢!
-
@TLama 使用“发布你的答案”;-)
-
你试过更新到最新版本5.4.1是否能解决问题?
-
@JoachimMarder 不,我没有。 TLama 建议有所帮助。