2

I use a virtualtreeview, and I want to show differents messages into the component, regardless columns, when no node visible.

Have you some idea to do this? Thank you.

r038tmp5
  • 105
  • 1
  • 5

1 Answers1

4

Write a handler for the OnPaintBackground event. For example:

procedure TForm1.VirtualStringTreePaintBackground(Sender: TBaseVirtualTree;
  TargetCanvas: TCanvas; R: TRect; var Handled: Boolean);
begin
  if Sender.VisibleCount = 0 then
  begin
    Handled := True;
    TargetCanvas.TextOut(10, 10, 'List has no visible nodes.');
  end;
end;

If you are interested in showing a text when the control is empty (not just when their nodes are hidden), you can use the EmptyListMessage property.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • Nice, thank you. I have just a problem with the VisibleCount property witch is invalid, but I create my own function. – r038tmp5 Aug 13 '15 at 09:45
  • You're welcome! Well, you must be using some ancient version. I would suggest you to update to the recent version. – TLama Aug 13 '15 at 10:41