Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

ElXTree: How to paint a custom bitmap in OnItemDraw


I'm using ElXTree as a grid. Column 0 should show a bitmap.

I tried many configurations, OwnerDrawByColumn, elhsOwnerDraw...... but I never get it work without changing the ElPack sources.

OnCellDraw paints the bitmap but then I have to paint everything, even the grid-lines, which i don't want to paint myself.

That can't be that complicated;)

Best regards

Andre Engelshove


  • 4 Comments sorted by Votes Date Added
  • Hi,

    >>That can't be that complicated;)<<
    OnCellDraw requires indeed the developer to paint all parts manually (however sources can be reviewed how to do that).
    Displaying an image column is simpler, though. Set either for the whole column Style to Image or ImageIndex or set at runtime for specific cells Style properties (the later technique is demonstrated in ElXTree MegaDemo, section "Using Images".

  • edited November 2014 Posts: 11Vote Up0Vote Down

    please take a look at the lines at line number 5876 in ElXTree.pas:

              if ((LCell.CurrentStyle.DrawStyle = elhsOwnerDraw) or (FOwner.FOwnerDrawByColumn and Assigned(LHeaderSection) and (LHeaderSection.Style = elhsOwnerDraw)))
                or (not FOwner.FOwnerDrawByColumn and (LCell.Text = FOwner.OwnerDrawMask)) then
                if Assigned(FOwner.FOnCellDraw) then
                  FOwner.FOnCellDraw(FOwner, LCell, ACanvas, R);

    If the style = OwnerDraw then only OnCellDraw will be called. OnItemDraw never.

    If I add the condition "and (not Assigned(FOwner.FOnItemDraw))" the grid-lines are there, OnItemDraw will be called in ElXTreeCell. Perfect.

    There is no way to set a column to OwnerDraw that the OnItemDraw-event will be fired.

    Best regards

    Andre Engelshove
  • >>There is no way to set a column to OwnerDraw that the OnItemDraw-event will be fired.<<
    The OnItemDraw event is indeed fired only for non-column/whole line/column-count=0 cases. Therefore simply checking the existence of OnItemDraw event as demonstrated above is not sufficient (for all customers).
    We'll check for a better solution in next SP.
Sign In or Register to comment.