我在VirtualTreeView节点上选择重新绘制有问题。当我在运行时更改节点文本并重新绘制树或实际聚焦的节点时,选择框不会更新。
在测试应用程序的屏幕下方(XE3,VT版本= 5.2.0)
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS81YnVrai5qcGcifQ==” alt =“更改前”>“>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS96MklmYS5qcGcifQ==” alt =“更改节点文本后-没有焦点的VirtualTreeView”>
我该如何解决这个问题?
我尝试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;
我在VirtualTreeView节点上选择重新绘制有问题。当我在运行时更改节点文本并重新绘制树或实际聚焦的节点时,选择框不会更新。测试应用程序的屏幕下方...
只需将问题关闭并标记为已解决,我将写@TLama的评论作为答案: