TComboBox multiple columns lazarus / 31-LCL ---------------------------------------------------------------------- xinyiman · 2010-07-15 07:53 How can a TComboBox use two or more columns in one row? ---------------------------------------------------------------------- JuhaManninen · 2010-07-15 09:06 Quote from: xinyiman on July 15, 2010, 09:53:58 amHow can a TComboBox use two or more columns in one row? This seems to work: Code: [Select]  ComboBox1.Items.Add('First '#9' item');   ComboBox1.Items.Add('Second '#9' item');   ComboBox1.Items.Add('Third '#9' item'); Tested with GTK2 and QT bindings, Linux, Lazarus trunk. Some 3rd party components may have more advanced features. Juha ---------------------------------------------------------------------- xinyiman · 2010-07-15 09:24 Windows not working properly, but then I wish the lines were aligned in various fields! is it possible? View image! ---------------------------------------------------------------------- JuhaManninen · 2010-07-15 09:46 Quote from: xinyiman on July 15, 2010, 11:24:58 amWindows not working properly, but then I wish the lines were aligned in various fields! is it possible? View image! Does it happen also with the Lazarus 0.9.29 trunk version on Windows? Juha ---------------------------------------------------------------------- zeljko · 2010-07-15 14:39 Under qt it's possible by adding another list class (TQtTreeWidget instead of TQtListWidget) and set number of columns, but it's hack. Normally TComboBox does not have multicolumn support, but you can use your own drawn combobox and format lines as you wish. ---------------------------------------------------------------------- fredycc · 2010-07-16 00:23 Hi zeljko, I have test it sucessfully under windows only , i'm sure the others platforms, check it: http://www.lazarus.freepascal.org/index.php/topic,9397.msg46031.html#m sg46031 ---------------------------------------------------------------------- Jordi March · 2019-03-08 17:08 I make a component (TComboBoxLkpDB), a ComboBox from TCustomEditButton. A dataset (with the content of columns) is required; for simple programs you can use a table in memory, for example, TBufDataset. You can download, provisionally, from my wiki: http://saniwiki.cat/lazarus/ListBoxLkpDB.zip. It contains 3 new components (TBufDatasetSort, TComboBoxLkpDB and TDBComboBoxLkpDB; that you can install in a new package) and one example. ---------------------------------------------------------------------- howardpc · 2019-03-08 19:04 @ Jordi March Thanks for sharing. However it needs more work. You should provide a package (.lpk) for the components, otherwise other users will most likely not get paths set correctly. Likewise, you should provide a project file (.lpi) for any example program, particularly a complex GUI such as your example, so that paths etc. are set up correctly. A .lpr is sufficient for, say, a simple console example, but not for the sort of example you give. You forgot to include the strutils0 unit which your example references, so it does not compile without amendment. However, since only one concatenation routine from it is used, why not just use the FPC concat() function? Also the example program you give has a memory leak at line 650 of the UpdateGridEdit routine in the ComboBoxLpkDB unit where you create columns. ---------------------------------------------------------------------- Jordi March · 2019-03-08 22:49 OK. I update the zip file with the other required files.  StrUtils0 unit was not necessary since was not included by directive; however, I deleted its reference. But not understand your last paragraph. Could you specify it or, directly, correct it? ---------------------------------------------------------------------- Ericktux · 2019-03-09 05:16 to load text + identifier in the combobox Imagine that we want to load several items inside the combobox, but that each item has a number that identifies it, very apart from its INDEX, its use can be to load tables or fields of a BD + your ID. here the codes: 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.Items.AddObject('casa', TObject(3));  // you load the text + yours ID (3)end; 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.Button2Click(Sender: TObject);begin  //Id := Integer(Combobox1.Items.Objects[Combobox1.ItemIndex]);  ShowMessage(in ttostr(Integer(Combobox1.Items.Objects[Combobox1.ItemIndex])));  // you obtain the ID as the elected itemend; to release the tobjects: 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 Combobox1.Items.Objects[ComboBox1.ItemIndex].Free greetings my friends. ---------------------------------------------------------------------- Jordi March · 2019-03-09 07:05 Ericktux, my component (TComboBoxLkpDB) doesn't use Items (since it is inherited from TCustomEditButton). Only Datasource with its Dataset. Then you determine what fields are displayed (as columns) with the Field.Visible property and what Field is lookup (lkp). Obviously you can add or delete records in runtime. Please, try use it and proof the example. The TComboBoxLkpDB functionality is similar to a ComboBox (with DropDown and DropDownList) and you can look up for other field types than the ftString or ftWideString (i.e. ftSmallint). ---------------------------------------------------------------------- howardpc · 2019-03-09 10:28 Quote from: Jordi March on March 08, 2019, 11:49:02 pmBut not understand your last paragraph. Could you specify it or, directly, correct it? You must specifically free any previous TGridCol instances created, before clearing the list. Otherwise they are orphaned by FGridCols.Clear, and leak memory that is then inaccessible. Add a couple of lines as follows: 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 TComboBoxLkpDB.UpdateGridEdit;var  I: Integer;  lDlgUnits: Integer;  GridCol: TGridCol;  PriorFont: TFont;begin  for I := 0 to FGridCols.Count-1 do             //< --- add these lines    TGridCol(FGridCols.Objects[I]).Free;  FGridCols.Clear;  if not Assigned (FLkpDataLink.Field) then Exit;    ... ---------------------------------------------------------------------- Jordi March · 2019-03-09 19:34 I change it. The new version, also in http://saniwiki.cat/lazarus/ListBoxLkpDB.zip. I had forgotten it, due to misunderstanding: The Lazarus explanation (https://www.freepascal.org/docs- html/rtl/classes/tstrings.clear.html) says "Clear will remove all strings and their associated objects from the list". The Delphi explanation is better (http://docs.embarcadero.com/products /rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classe s_TStringList_Clear.html): "All references to associated objects are also removed. However, the objects themselves are not freed." Then I think the Lazarus help should be modified to avoid errors... Finally, the Lazarus compiler didn't (before the last correction) detect a memory leak (unlike the demo http://forum.lazarus.freepascal. org/index.php?action=dlattach;topic=31598.0;attach=14618). Why? Very thank you. Jordi. ---------------------------------------------------------------------- xinyiman · 2019-03-11 07:45 Error, not found StrUtil0 library. ---------------------------------------------------------------------- Jordi March · 2019-03-11 10:21 Sorry, solved! ---------------------------------------------------------------------- xinyiman · 2019-03-11 13:30 Now not exist lpk file ---------------------------------------------------------------------- Jordi March · 2019-03-13 16:17 Solved!. An error on packing the files. .  I add xml files for help in IDE integration... but I do not know how to make them work.