Recent

Author Topic: Trouble with TFilteredComboBox  (Read 2489 times)

simsee

  • Full Member
  • ***
  • Posts: 184
Trouble with TFilteredComboBox
« on: April 26, 2020, 12:25:16 am »
Dear all, I want to use TFilteredComboBox, but I'm not able to obtain that the elements showed in the list dynamically change according to chars typed in the edit of control. I have tried to set Style property with all the allowed values. How is it possible to realize the desired behavior? Thanks.
« Last Edit: April 26, 2020, 12:37:45 am by simsee »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Trouble with TFilteredComboBox
« Reply #1 on: April 26, 2020, 02:05:01 am »
Yes. looks like someone hacked it to put the TShellListview in it instead..

 even that does not work correct ether..

the FileList property is no longer there but it still shows in the code view help..

As for your autocomplete not working, I see that is also broke..
if you want to use that you can do this..
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FilterComboBox1Change(Sender: TObject);
  2. begin
  3.   FilterComboBox1.ItemIndex := FilterComboBox1.Items.IndexOf(FilterComboBox1.Caption);
  4.   FileListBox1.Mask := FilterComBoBox1.Mask;
  5. end;  
  6.  
  7.  I suppose that code could even be put in the control to fix it. Who knows..
  8.                                              
  9.  
The only true wisdom is knowing you know nothing

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Trouble with TFilteredComboBox
« Reply #2 on: April 26, 2020, 07:40:23 am »
Where can you find  TFilteredComboBox?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Trouble with TFilteredComboBox
« Reply #3 on: April 26, 2020, 07:50:50 am »
ctrl+alt+p and type filter its the first of a list of 5. If I change to the palette tab it gives it under the misc page.

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Trouble with TFilteredComboBox
« Reply #4 on: April 26, 2020, 07:54:33 am »
From the IDE is in the 'Misc' tab (the icon with a funnel).
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

simsee

  • Full Member
  • ***
  • Posts: 184
Re: Trouble with TFilteredComboBox
« Reply #5 on: April 26, 2020, 08:02:29 am »
Yes. looks like someone hacked it to put the TShellListview in it instead..

 even that does not work correct ether..

the FileList property is no longer there but it still shows in the code view help..

As for your autocomplete not working, I see that is also broke..
if you want to use that you can do this..
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FilterComboBox1Change(Sender: TObject);
  2. begin
  3.   FilterComboBox1.ItemIndex := FilterComboBox1.Items.IndexOf(FilterComboBox1.Caption);
  4.   FileListBox1.Mask := FilterComBoBox1.Mask;
  5. end;  
  6.  
  7.  I suppose that code could even be put in the control to fix it. Who knows..
  8.                                              
  9.  
Thanks Jamie. But I'm non sure to understand. Do I need an additional listbox? Can't I use the stringlist (items property) built into tfiltercombobox?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Trouble with TFilteredComboBox
« Reply #6 on: April 26, 2020, 09:36:10 am »
From the IDE is in the 'Misc' tab (the icon with a funnel).
Ahh, TFilterComboBox, not TFilteredComboBox!
Ok, I have not played much with that component.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

simsee

  • Full Member
  • ***
  • Posts: 184
Re: Trouble with TFilteredComboBox
« Reply #7 on: April 26, 2020, 10:24:14 am »
 Yes, I'm sorry for my typo...

From the IDE is in the 'Misc' tab (the icon with a funnel).
Ahh, TFilterComboBox, not TFilteredComboBox!
Ok, I have not played much with that component.


wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Trouble with TFilteredComboBox
« Reply #8 on: April 26, 2020, 11:39:46 am »
I want to use TFilteredComboBox, but I'm not able to obtain that the elements showed in the list dynamically change according to chars typed in the edit of control. I have tried to set Style property with all the allowed values.
Are you sure that TFilterCombobox is what you need? It cooperates with a ShellListView and "Filter" is here understood as a filter for file types allowing you to see in the ShellListView, for example, only the .pas files.

Your description sounds as if you are seeking for the TListFilterEdit on palette LazControls. It is an edit linked to a separate listbox ("FilteredListbox"): whatever you type in the edit will be used as a filter to display ony those listbox items which match the filter string.
« Last Edit: April 26, 2020, 11:41:36 am by wp »

simsee

  • Full Member
  • ***
  • Posts: 184
Re: Trouble with TFilteredComboBox
« Reply #9 on: April 26, 2020, 12:02:04 pm »
I have evaluate the use of TListFilterEdit, but the associated listbox is not dropdown.

simsee

  • Full Member
  • ***
  • Posts: 184
Re: Trouble with TFilteredComboBox
« Reply #10 on: April 26, 2020, 12:12:17 pm »
I need this: https://en.wikipedia.org/wiki/Combo_box. The basic TComboBox behaves in a different way, so I tought to use TFilterComboBox.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Trouble with TFilteredComboBox
« Reply #11 on: April 26, 2020, 12:54:53 pm »
I don't know of such a control, at least not within the standard Lazarus distribution. Maybe in JVCL, but certainly not among the fraction of components ported to Lazarus. Maybe in somebody else's componentset, I don't know.

You could still use the TListFilterEdit when you hide the listbox initially. Add a speedbutton for the dropdown arrow. Add code which shows the listbox when the speedbutton is clicked or text is typed into the ListFilterEdit. Add code which hides the listbox when a listbox item is selected. It may get difficult to achieve the standard behavior of a combobox, though.

The question is also: Is this worth the effort? Why is the standard AutoComplete feature of TCombobox not enough?

P.S.
Just found this: https://stackoverflow.com/questions/6667054/how-can-i-filter-the-contents-of-a-combo-box-based-on-whats-been-typed. Maybe it is helpful?
« Last Edit: April 26, 2020, 01:01:43 pm by wp »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Trouble with TFilteredComboBox
« Reply #12 on: April 26, 2020, 01:14:42 pm »
The standard Tcombobox will do as you ask If I understand you correctly ?

You need to set two properties.

AutoComplete := true;
AutoDropDown := true;

and maybe the AutoCompleteText needs to be looked at too. This will allow you to configure how you want it to search the list.

 If you are looking to keep a listbox open at all times on the form then you need to combine two controls but I don't think that is what you are after.
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Trouble with TFilteredComboBox
« Reply #13 on: April 26, 2020, 01:17:54 pm »
The standard Tcombobox will do as you ask If I understand you correctly ?

You need to set two properties.

AutoComplete := true;
AutoDropDown := true;

and maybe the AutoCompleteText needs to be looked at too. This will allow you to configure how you want it to search the list.
But if I did not miss anything in my experiments, it will not filter the dropdown list.

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Trouble with TFilteredComboBox
« Reply #14 on: April 26, 2020, 01:32:02 pm »
ok, then maybe I am mistaken, too.  :(

if that is the case then could it be just that he wants a custom loaded drop down..

almost like a word search in a dictionary where as the auto complete is actually in the list..
 
 But that would mean a loaded list needs of all possibilities needs to be in a Tstringlist and the Onchange needs to reload the list each time for matches.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018