Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:44:37+00:00 2026-06-15T23:44:37+00:00

I’ve for a virtualstringtree control on my form which has to display icons from

  • 0

I’ve for a virtualstringtree control on my form which has to display icons from an imagelist for certain nodes. This works fine, however, it also has to display custom drawn icons that are as tall as the node and square, for certain nodes.

I’m using the OnBeforeCellPaint event to draw these images and change the ContentRect to accommodate for the extra space it requires in the item.

ContentRect.Offset(ContentRect.Height + 4, 0);

(The +4 is there to have the same spacing from the “icon” for the text as with the ones loaded from the imagelist)

This method seems to work fine, the nodes are drawn correctly and the selection rectangles are as well. However, the hitboxes for clicking the nodes don’t seem to get updated. I have to click the original ContentRect to select the node.

How do I update the hitbox?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:44:38+00:00Added an answer on June 15, 2026 at 11:44 pm

    What to avoid ?

    Don’t modify the ContentRect in the OnBeforeCellPaint if you want to change the size of a node. The ContentRect rectangle in the OnBeforeCellPaint event is for modifying the place, where the cell will be rendered. It doesn’t actually modify the size of a node. By that ContentRect offset you just moved painting out of the node’s physical position, out from the position where the node can be clicked.

    How to adjust node height ?

    The default, fixed node height is defined by the DefaultNodeHeight property. When you don’t know the node height you need in advance, you can write the handler for the OnMeasureItem event. There you can modify the NodeHeight parameter value to adjust the height of a node.

    When you’ll be handling the OnMeasureItem event, be sure to include the toVariableNodeHeight option to the TreeOptions.MiscOptions option set.

    How to adjust node width ?

    For TVirtualStringTree control specifically, the node width is calculated by the measured node text width increased by 2 * text margin (adjustable by the TextMargin property). During the node text width measurement the OnMeasureTextWidth event is fired having the declared Extent parameter, which contains the measured text width. By modifying this Extent parameter, you’ll affect the overall width of a node since this event is internally used just for this purpose.

    So, to increase each node width e.g. by 20 pixels, you can write the following:

    procedure TForm1.VirtualStringTree1MeasureTextWidth(Sender: TBaseVirtualTree;
      TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
      const Text: string; var Extent: Integer);
    begin
      Extent := Extent + 20;
    end;
    

    Here is the result without and with the text extent modified:

    enter image description here

    For TVirtualDrawTree control is the situation much easier. It has the OnGetNodeWidth event, that is used to specify a node width through its NodeWidth declared parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I have an array which has BIG numbers and small numbers in it. I
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.