EhLib.Com
https://forum.ehlib.com/en/

How to put icons in TreeView?
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1049
Page 1 of 1

Author:  Luciano_F [ 23 Jul 2020, 19:02 ]
Post subject:  How to put icons in TreeView?

I looked in the examples but I didn't find it.

I have a TreeView that represents a Menu of system modules and I would like each node to have an icon how could I do that?

I could change the project "\Demos\DBGridEh.TreeView" with different icons on each node for me to understand.

Another thing I wanted to change is the icon that represents the node I wanted a different icon or increase the size because the current one is very small see the image.


Thankful.

Attachments:
Icon_Pequeno.png
Icon_Pequeno.png [ 46.06 KiB | Viewed 2205 times ]

Author:  EhLibSupport [ 27 Jul 2020, 20:46 ]
Post subject:  Re: How to put icons in TreeView?

Hello

Look at the Demo project \Demos\DBGridEh.TreeView.Solutions\
It have section 'Checkboxes in a Tree' (File FrameFour.pas).
Attachment:
sshot-128.png
sshot-128.png [ 75.44 KiB | Viewed 2188 times ]


Checkboxes are displayed in grid cells using images from the ImageList component.

To display a picture from the ImageList component, you need to make the following settings in the column.

Column.ImageList = ImageList1
Column.ShowImageAndText = True
Column.TextEditing = False

Write Column.OnGetCellParams event handle where image index is assigned to Params.ImageIndex for every record of DataSet.

Code:
procedure TfrFrameFour.DBGridEh1Columns0GetCellParams(Sender: TObject;
  EditMode: Boolean; Params: TColCellParamsEh);
begin
  Params.ImageIndex := MemTableEh1.FieldByName('ImageIndex').AsInteger;
end;


In this example, the picture number is already stored in the DafaSet field - ImageIndex.

-----
About drawing the Plus / Minus tree icons.
Unfortunately, this function is hardcoded.
You need to rewrite the function
procedure TCustomDBGridEh.DrawGridTreeElement.

Author:  Luciano_F [ 28 Jul 2020, 00:29 ]
Post subject:  Re: How to put icons in TreeView?

Hello it worked the icons were good.

However, the size of the Nodes are very small. Would there be any way for me to change the method overload so I don't need to modify the component every time I update it?

Or a property could be created so that we can place the Icon as a Node, or a property to change the size of the Node.

Thankful.

Attachments:
Icon_Pequeno.png
Icon_Pequeno.png [ 190.25 KiB | Viewed 2188 times ]

Author:  EhLibSupport [ 26 Aug 2020, 14:12 ]
Post subject:  Re: How to put icons in TreeView?

Hello.

Do you mean the Plus / Minus Icon that shows the branch's open status?
Unfortunately in the current version there is no such possibility.
We have added this request to the list for the next version of the library.

Author:  Luciano_F [ 26 Aug 2020, 14:31 ]
Post subject:  Re: How to put icons in TreeView?

this the plus and minus icons, a way to increase this icon that is very small in full HD and 4K resolution

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/