Combo Box Behavior lazarus / 31-LCL ---------------------------------------------------------------------- whiffee · 2017-05-21 19:30 I have a problem with the Combo Box. I assign a long list of items, pre-alphabetized, and then I may search for a starting string. In code written in Delphi 5 the behavior is as follows: the closest match is shown in the Combo Box edit field. If the list is dropped down, the search point is displayed, with items before and after and the match item in the middle. Good. The same code compiled by Lazarus 1.6 does not behave this way. The search runs and succeeds, and the match is shown in the edit field. But when the list is dropped down, the top of the list only is shown. The match is nowhere to be seen. Maybe I'm not populating the item list the right way. Below is some code. Any suggestions are appreciated. procedure TForm1.GetData(Sender: TObject); var    lines, i, j, lastverb, lastverbplus : Integer;    verbname : string; begin    fileData := TStringList.Create;    fileData.LoadFromFile('Verb12Data.txt');    lines := fileData.Count;    verbname := '';    if frac(lines / 395) <> 0.0000 then PJVCLMsgDlg1.execute;     lastverb := (lines div 396);    lastverbplus := (lastverb div 395);    lastverb := lastverb + lastverbplus;     for i := 0 to lastverb do begin     j := 395*i;     verbname := fileData[j];     Delete(verbname, 1, 30);     ComboBox1.Items.Add(' ' + verbname);     end;     ComboBox1.Itemindex := 0;     RefreshEBoxes(Sender);     end;    thanks, Whiffee ---------------------------------------------------------------------- valdir.marcos · 2017-05-21 21:27 Quote from: whiffee on May 21, 2017, 09:30:29 pmI have a problem with the Combo Box. I assign a long list of items, pre-alphabetized, and then I may search for a starting string. In code written in Delphi 5 the behavior is as follows: the closest match is shown in the Combo Box edit field. If the list is dropped down, the search point is displayed, with items before and after and the match item in the middle. Good. The same code compiled by Lazarus 1.6 does not behave this way. The search runs and succeeds, and the match is shown in the edit field. But when the list is dropped down, the top of the list only is shown. The match is nowhere to be seen. Maybe I'm not populating the item list the right way. Below is some code. Any suggestions are appreciated. This simple example in Lazarus 1.6.4 behaves just the way you explained in Delphi5: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  ComboBox1.AutoComplete := True;  ComboBox1.Clear;  ComboBox1.Items.Clear;  ComboBox1.Items.Add('aaa');  ComboBox1.Items.Add('bbb');  ComboBox1.Items.Add('ccc');  ComboBox1.Items.Add('ddd');  ComboBox1.Items.Add('eee');  ComboBox1.Items.Add('fff');  ComboBox1.Items.Add('ggg');  ComboBox1.Items.Add('hhh');  ComboBox1.Items.Add('iii');  ComboBox1.Items.Add('jjj');  ComboBox1.SetFocus;end; ---------------------------------------------------------------------- whiffee · 2017-05-21 23:52 My question was not very clear. If the Combo Box has less than 25 items, a dropdown will always show them all. I tried your snippet with 49 items, then executed a procedure to show one with an index number greater than 25, the same thing a search would do. The item appeared in the edit box, but not in the dropdown. I can ask my question another way: Is there any way to get a Combo Box dropdown  that does not show the top of the list? My understanding of Laz is poor, but I suspect the answer is no. Thanks for your reply by the way. regards, Whiffee ---------------------------------------------------------------------- valdir.marcos · 2017-05-22 01:20 Quote from: whiffee on May 22, 2017, 01:52:12 amMy question was not very clear. If the Combo Box has less than 25 items, a dropdown will always show them all. I tried your snippet with 49 items, then executed a procedure to show one with an index number greater than 25, the same thing a search would do. The item appeared in the edit box, but not in the dropdown. I can ask my question another way: Is there any way to get a Combo Box dropdown  that does not show the top of the list? My understanding of Laz is poor, but I suspect the answer is no. Maybe, you should make a video (and convert it to GIF), so we can better understand your viewpoint. Meanwhile, try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  i, j, k: byte;begin  ComboBox1.AutoComplete := True;  ComboBox1.Clear;  ComboBox1.Items.Clear;  for i := 97 to 122 do    for j := 97 to 122 do      for k := 97 to 122 do        ComboBox1.Items.Add(chr(i)+chr(j)+chr(k));  ComboBox1.SetFocus;end; ---------------------------------------------------------------------- HeavyUser · 2017-05-22 01:26 Quote from: valdir.marcos on May 22, 2017, 03:20:02 amMaybe, you should make a video (and convert it to GIF), so we can better understand your viewpoint. He probably means that the drop down list does not Auto scroll to the selected item when opened. Probably only when the selection is done from code or some other set of conditions not well defined at this point. ---------------------------------------------------------------------- valdir.marcos · 2017-05-22 01:35 Quote from: HeavyUser on May 22, 2017, 03:26:43 amQuote from: valdir.marcos on May 22, 2017, 03:20:02 amMaybe, you should make a video (and convert it to GIF), so we can better understand your viewpoint. He probably means that the drop down list does not Auto scroll to the selected item when opened. Probably only when the selection is done from code or some other set of conditions not well defined at this point. Maybe this other one: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  i, j, k: byte;begin  ComboBox1.AutoComplete := True;  ComboBox1.AutoDropDown := True;  ComboBox1.Clear;  ComboBox1.Items.Clear;  for i := 97 to 122 do    for j := 97 to 122 do      for k := 97 to 122 do        ComboBox1.Items.Add(chr(i)+chr(j)+chr(k));  ComboBox1.SetFocus;end; ---------------------------------------------------------------------- whiffee · 2017-05-22 03:03 hi valdir, thanks for your attention. I tried your latest code variation and I'm still getting the same thing. (Two browsers in Linux and two in OSX are refusing to show a forum post 'reply' icon, so I'm pecking this out on a tablet.) As for the problem description, suppose I have 5000 items in a Combo Box and I'm doing a search. The items are strings but I'm interested in results that are close to the best match. The best match is available in the text box, but there's no way I'm going to be able to scroll by hand to the result's location to examine the near results. I realize there are other ways to approach this, but for now a combo box is a convenient container that can easily be manipulated from the U/I, and repeated searches done with quick results available. If HeavyUser doesn't mind my putting in a piggy-backed response, the term 'AutoScroll' seems to fit well. Does TComboBox have such a thing? Thanks again for following. regards, Whiffee ---------------------------------------------------------------------- valdir.marcos · 2017-05-22 04:09 There are 17,576 items (263 or 26 x 26 x 26) in my combobox example. In my example, type "def", then press arrow down and up on your keyboard. That is a possible solution where you can navigate on the combobox near search result. Beyond that, I need a video to understand what exactly you mean. ---------------------------------------------------------------------- whiffee · 2017-05-22 14:15 hi valdir, My last post was not posted for some reason. I observed that the trick with the arrow keys is a good one to know about. By clicking at the right time it is not necessary to re-select the contents of the edit box to go up one item or down one. Still, this solution does not equal the convenience of being able to see the box index point and its surroundings at one glance. thanks much for your help. regards, whiffee ---------------------------------------------------------------------- valdir.marcos · 2017-05-22 15:12 You're welcome.