Recent

Author Topic: TTabControl images  (Read 4107 times)

mtanner

  • Sr. Member
  • ****
  • Posts: 287
TTabControl images
« on: April 02, 2016, 12:52:21 pm »
This is probbaly an idiot's question.

I have a TTabControl with an imagelist assigned to the Images property of the TTabControl. But the images do not appear on the tabs. Apart from assigning the imagelist, what else do I have to do to make the images appear?i

wp

  • Hero Member
  • *****
  • Posts: 10298
Re: TTabControl images
« Reply #1 on: April 02, 2016, 04:02:30 pm »
Use the OnGetImageIndex event.

mtanner

  • Sr. Member
  • ****
  • Posts: 287
Re: TTabControl images
« Reply #2 on: April 03, 2016, 12:19:27 am »
Could you please elaborate a bit more? What I expected was for the imagelist for a TTabControl to operate like an imagelist for a popupmenu or a toolbar, where assigning the imagelist and image indices for the components is enough, with no need for user-coding in events.

wp

  • Hero Member
  • *****
  • Posts: 10298
Re: TTabControl images
« Reply #3 on: April 03, 2016, 01:33:22 am »
Hey come on, what is the problem to double-click at the OnGetImageIndex event of the TTabControl and look at the auto-generated code? You will see immediately how you can assign an image index to a tabsheet. It is a bit different from what you know from a menu item or toolbutton because all tabs of the TTabControl are the same, they only differ by their caption which is defined in a stringlist..

mtanner

  • Sr. Member
  • ****
  • Posts: 287
Re: TTabControl images
« Reply #4 on: April 03, 2016, 04:35:13 pm »
Well of course I can easily create an OnGetImageIndex event. I tried using the event to assign an ImageIndex, no difference. The event handler is actually receiving the correct ImageIndex any way. (The ImageIndex value I'd want to use will allways be the TabIndex value, which is the default. )

To be clear, I'm talking about a TTabControl, not a TPageControl. With TPageControl, if I assign an imagelist to the TPageControl.Images, then set the ImageIndex property of a contained TTabsheet, then the image referenced appears on the tab, just as I'd expect.

wp

  • Hero Member
  • *****
  • Posts: 10298
Re: TTabControl images
« Reply #5 on: April 03, 2016, 05:04:26 pm »
Now I tried it myself, and yes, you are right - there are no images at the tabs of a TTabcontrol although Images are assigned to it and there is a handler for the OnGetImageIndex event. This seems to be a bug. Please write a bug report that somebody can take care of it. Add a little project to the report to demonstrate the issue (only pas, lfm, lpi and lpr files, no exe, ppu or other files generated by the compiler; all packed into a single zip).

Mastropiero

  • New Member
  • *
  • Posts: 19
Re: TTabControl images
« Reply #6 on: July 31, 2022, 09:11:34 pm »
Sorry for the thread necromancy...  I've stumbled upon this topic 6 years ago and it seems to still remain the same.

Does anybody know if this was finally reported as a bug?

dsiders

  • Hero Member
  • *****
  • Posts: 726
Re: TTabControl images
« Reply #7 on: August 01, 2022, 02:37:51 am »
Sorry for the thread necromancy...  I've stumbled upon this topic 6 years ago and it seems to still remain the same.

Does anybody know if this was finally reported as a bug?

Yes, it was reported 9 years ago. https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/23068.

Why it is in a TAChart forum is a mystery though.
Preview Lazarus 2.3.0 documentation at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018