【问题标题】:Selection doesn't repaint VirtualTreeView选择不会重绘 VirtualTreeView
【发布时间】: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 建议有所帮助。

标签: delphi virtualtreeview


【解决方案1】:

为了可以关闭问题并将其标记为已解决,我将写 @TLama 的评论作为答案:

使用InvalidateNode

【讨论】:

    猜你喜欢
    • 2012-10-03
    • 2016-03-13
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多