TVirtualStringTree.OnGetText Event

Virtual Tree View

Virtual string tree event to query for a node's normal or static text.

Pascal
property OnGetText: TVSTGetTextEvent;
Description

This is one of the fundamental string tree events which must always be handled. The string tree will fire this event every time when it needs to know about the text of a specific node and column. This is mainly the case when the node appears in the visible area of the tree view (in other words it is not scrolled out of view) but also on some other occasions, including streaming, drag and drop and calculating the width of the node. 

 

The node text is distinguished between two text types: 

 

 

  • Normal text: If TextType is ttNormal return the main node caption for the specified column.
  • Static text: All text that you return when TextType is ttStatic will be displayed right beside the normal text (or left to it if the column's BidiMode is not bdLeftToRight, i.e. the column has right-to-left layout). Static text is used only for informational purposes; it cannot be selected or dragged and if the column is not wide enough to show all text it will not be shortened with an ellipsis (...) as normal text. The string tree will only query for static text if the StringOptions (see TreeOptions) include toShowStaticText. This is off by default.

 

 

When this event is fired the text parameter will always be initialized with the value of property DefaultText. To handle the event get your node data and then extract the string for the appropriate column and TextType.

Notes

Be sure that your event handler only contains absolutely necessary code. This event will be fired very often - easily a 

few hundred times for medium sized trees with some columns defined when the tree is repainted completely. 

For example it is far too slow to use Locate() on some Dataset, a database query result or table, and then get the text 

from some TField. This may only work with in-memory tables or a client dataset. When you initialize your node data do 

some caching and use these cached values to display the data.

See Also

OnPaintText

Class
Links
What do you think about this topic? Send feedback!