Board index » delphi » Different TTreeNode fonts in TTreeView?

Different TTreeNode fonts in TTreeView?

With TTreeView, I would like to show that some TTreeNodes are pointing to
data that can be edited while some are pointing to data that is
fixed/uneditable.

Is is possible to set the font style for TTreeNode labels in TTreeView so
that TTreeNodes pointing to editable data is shown with normal text while
those pointing to uneditable data is shown with italicized or greyed out
text?  I fear that this may not be possible because TTreeView a wrapper for
the Win32 Tree-View control.  Am I correct?

I may have to resort to the image approach although I prefer not to take up
the additional screen space.

TIA.
Raymond Yap

 

Re:Different TTreeNode fonts in TTreeView?


Hello Raymond,

the only way I know is to react on the TreeView's OnCustomDrawItem or
OnAdvancedCustomDrawItem event.
As in this case OnCustomDrawItem is more appropriate.

Your event-handling code might look like this:

procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if { treenode is editable }
    then TreeView1.Canvas.Font.Style := [fsBold];
  // DefaultDraw is set to true by default so we don't need to do this
end;

best regards
Ruediger

Re:Different TTreeNode fonts in TTreeView?


A example in Delphi5\Demos\CustomDraw diferents fonts when i select a node

Raymond Yap escribi:

Quote
> With TTreeView, I would like to show that some TTreeNodes are pointing to
> data that can be edited while some are pointing to data that is
> fixed/uneditable.

> Is is possible to set the font style for TTreeNode labels in TTreeView so
> that TTreeNodes pointing to editable data is shown with normal text while
> those pointing to uneditable data is shown with italicized or greyed out
> text?  I fear that this may not be possible because TTreeView a wrapper for
> the Win32 Tree-View control.  Am I correct?

> I may have to resort to the image approach although I prefer not to take up
> the additional screen space.

> TIA.
> Raymond Yap

Re:Different TTreeNode fonts in TTreeView?


Quote
In article <3a93ebcf_1@dnews>, Raymond Yap wrote:
> Is is possible to set the font style for TTreeNode labels in TTreeView so
> that TTreeNodes pointing to editable data is shown with normal text while
> those pointing to uneditable data is shown with italicized or greyed out
> text?

Try setting the TTreeNode Cut property.

 Mike Orriss (TeamB & Developer Express)
 (Unless stated otherwise, my replies relate to Delphi 5)
 (No unsolicited e-mail replies please)

Other Threads