Recent

Author Topic: TComboBoxEx & TCheckComboBox - how do they work?  (Read 7984 times)

JD

  • Hero Member
  • *****
  • Posts: 1913
TComboBoxEx & TCheckComboBox - how do they work?
« on: January 12, 2016, 12:38:31 pm »
Hi there everyone,

I'm curious to know how more about how TComboBoxEx & TCheckComboBox work?

I see that TComboBoxEx permits adding images but I'd like to know how it works.

I don't get why TCheckComboBox permits checking multiple options yet displays only one option in the edit field.

Thanks,

JD
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

balazsszekely

  • Guest
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #1 on: January 12, 2016, 01:10:01 pm »
Hi JD,

1. TComboBoxEx
   Add a TImageList to your form, assign TImageList to TCombobBoxEx Images property. Add a few ItemEx, and set each ItemEx ImageIndex property.
2. TCheckComboBox
    I guess you can store one extra info in the checkboxes(if needed), but you're right, it's counter intuitive.

regards,
GetMem

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #2 on: January 12, 2016, 02:52:21 pm »
I developed those two components some time ago and I can tell that it was not easy to make it (even more: make it cross-platform) because you don't have full control and no mouse events over the drop-down menu, you can click just once. So it's a compromise.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

balazsszekely

  • Guest
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #3 on: January 12, 2016, 04:44:13 pm »
@Blaazen
Those are great components, especially TComboBoxEx. TCheckComboBox is also good, I don't have problem with multiple clicks(what you mentioned as a compromise), I just don't understand the logic. Let's say we have five items, four of them is checked(0, 2, 3, 4), the ItemIndex is 0(the first one is displayed). Now which counts? The checked items, the displayed item or both? I think this is also the OP's question.     
« Last Edit: January 12, 2016, 04:48:20 pm by GetMem »

JD

  • Hero Member
  • *****
  • Posts: 1913
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #4 on: January 12, 2016, 05:35:56 pm »
Yes Blaazen. The components are great. I thought about using TComboBoxEx when I wanted to have a combobox with countries & their flags.

I was just looking for examples of their proper usage.

JD
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 13543
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #5 on: January 12, 2016, 05:38:21 pm »
I've seen a component similar to TCheckCombobox in which the edit field displays a semicolon (or whatever)-separated list of the checked items, i.e., if the combobox contains items "Red", "Green", "Blue", "Yellow", and "Red" and "Yellow" are checked then the edit line displays the text "Red;Yellow" (without a checkbox).

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #6 on: January 12, 2016, 06:53:18 pm »
Now it works this way:
Let's say you have 5 items (Count=5). You dropdown list, click the third item. Now (ItemIndex=2), and the third item is selected. You can change this item without dropping down the list.

Known limitations:
You cannot sort items (it will mess checkboxes and captions).
You cannot change state of selected item in dropdown menu (you have to click selected item directly when combo is closed).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

balazsszekely

  • Guest
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #7 on: January 13, 2016, 09:36:12 am »
Quote
@JD
I thought about using TComboBoxEx when I wanted to have a combobox with countries & their flags.
Take a look at this: https://drive.google.com/file/d/0B9Me_c5onmWoeUdIT1ctbnJ2UzA/view?usp=sharing

JD

  • Hero Member
  • *****
  • Posts: 1913
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #8 on: January 13, 2016, 12:47:56 pm »
Quote
@JD
I thought about using TComboBoxEx when I wanted to have a combobox with countries & their flags.
Take a look at this: https://drive.google.com/file/d/0B9Me_c5onmWoeUdIT1ctbnJ2UzA/view?usp=sharing

@GetMem
Thanks a lot for this. It was exactly what I was planning to do.

JD
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

balazsszekely

  • Guest
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #9 on: January 13, 2016, 01:04:18 pm »
@JD

You're welcome! I just noticed:
1. Form 222 to 225 the order are switched. Please make the necessary adjustments.
2. The autocomplete features are not working at my side. It would be nice if, for example type f, then the first country with f would appear.

pmralbuquerque

  • New Member
  • *
  • Posts: 44
    • GitHub
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #10 on: May 09, 2026, 05:24:34 pm »
Now it works this way:
Let's say you have 5 items (Count=5). You dropdown list, click the third item. Now (ItemIndex=2), and the third item is selected. You can change this item without dropping down the list.

Known limitations:
You cannot sort items (it will mess checkboxes and captions).
You cannot change state of selected item in dropdown menu (you have to click selected item directly when combo is closed).

I know this is an old post, please forgive.

@blaazen, thank you for these.

Let's say I have 5 items in TCheckComboBox. I want to loop through those 5 items and concat all checked items in a string. Something like this:
Code: Pascal  [Select][+][-]
  1. for Counter := 0 to cbCheckProjects.Count do
  2.     begin
  3.       if cbCheckProjects.ItemIndex[Counter].Checked then  // Illegal qualifier error
  4.          ProjectList += ',' + cbCheckProjects.ItemIndex[Counter].Text;
  5.     end;
  6.  

Is this possible?

Thank you in advance,
Pedro
Lazarus 4.4 / FPC 3.2.2
Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz   2.60 GHz RAM 16,0 GB
Windows 10 upgraded to 11

Paolo

  • Hero Member
  • *****
  • Posts: 717
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #11 on: May 09, 2026, 06:05:59 pm »
Something like this compile ?

Code: Pascal  [Select][+][-]
  1. for Counter := 0 to cbCheckProjects.Count-1 do  // added -1
  2.     begin
  3.       if cbCheckProjects.Items[Counter].Checked then  // items instead of your itemindec
  4.          ProjectList += ',' + cbCheckProjects.Items[Counter].Text; // as above
  5.     end;
  6.  

pmralbuquerque

  • New Member
  • *
  • Posts: 44
    • GitHub
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #12 on: May 09, 2026, 06:13:25 pm »
Thank you for your time Paolo.

No, illegal qualifier is still there. I should have said that Checked is my wishfull thinking, pseudo code. Not sure if there is such a possibility.
Lazarus 4.4 / FPC 3.2.2
Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz   2.60 GHz RAM 16,0 GB
Windows 10 upgraded to 11

Paolo

  • Hero Member
  • *****
  • Posts: 717
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #13 on: May 09, 2026, 07:10:08 pm »
This ?

Code: Pascal  [Select][+][-]
  1.    If  cbCheckProjects.Checked[I] then...
  2.  

pmralbuquerque

  • New Member
  • *
  • Posts: 44
    • GitHub
Re: TComboBoxEx & TCheckComboBox - how do they work?
« Reply #14 on: May 10, 2026, 07:31:59 am »
Paolo,
That did it, perfect, many thanks. It ended like so:

Code: Pascal  [Select][+][-]
  1. for Counter := 0 to cbCheckProjects.Count-1 do
  2.     begin
  3.       if cbCheckProjects.Checked[Counter] then
  4.          ProjectList += ',' + cbCheckProjects.Items[Counter];
  5.     end;      
  6.  
Lazarus 4.4 / FPC 3.2.2
Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz   2.60 GHz RAM 16,0 GB
Windows 10 upgraded to 11

 

TinyPortal © 2005-2018