TListView on linux lazarus / 1-Linux ---------------------------------------------------------------------- MikeFinch · 2009-08-02 01:59 Further to mine of yesterday : I ported the Windows code to my linux equivalent program, with the result that I AM STILL GETTING ONE COLUMN ONLY! : on the left and it is the full list (A to Z). The pseudocode that works in Windows lazarus is as below; am I just lucky (i.e. is the coding technically wrong) and what changes should I make to get the linux version working as I want (multiple columns)? var   i : smallint;   ListItem : TListItem; begin   ActFile := 1; //this is for current players; it is 0 for archived players   //the caption for the window   with CurrPlayers.ListView1 do begin     Clear;     for i := 0 to MaxRecords-1 do begin       ListItem := Items.Add;       ListItem.Caption := KList[ActFile,i].name; //KList is sorted by surname (+ firstname)       ListItem.SubItems.Add((ListItem.Caption));     end; //multiple columns in Windows, only 1 column in linux     CurrPlayers.Show; //show the form     Show; //Show the ListView   end; end;  I also need to click on any name to bringup the player's details. Using ListBox I found ListBox1.selected worked, but not with ListView. Is there a ListView.Index or suchlike to identify the selected listmember? Since installing L0.9.27 (.26 was no good because ComboBox.OnChange wouldn't work) I've lost the ability to bring up a hintbox after pressing ".". E.g. ListView then '.' would bringup a list of procedures, propertys, etc applicable to ListView. Can anyone remind me please how to reinstall this very helpful aid? Another problem : when I display a showmessage (or messagedlg) box the underlying window vanishes. (Doesn't in Windows lazarus). How can I keep the underwindow visible - as I want, please anyone? ---------------------------------------------------------------------- theo · 2009-08-02 08:48 Set ViewStyle to vsReport and add as many columns as you need using the Columns property. Short snippet to show that it works (GTK2): Code: [Select]var li:TListItem; begin  ListView1.ViewStyle:=vsReport;  ListView1.Columns.Add;  ListView1.Columns.Add;  li:=ListView1.Items.Add;  li.Caption:='test';  li.SubItems.Add('test1'); end; AND never ever use the "with" keyword this way (or at all). It is often the source of mysterious problems. Selecting: Code: [Select]procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem;   Selected: Boolean); begin   ShowMessage(Item.Caption); end; Have a look at the properties and events in the OI to find such things. ---------------------------------------------------------------------- MikeFinch · 2009-08-03 02:28 Theo : thanks for your informative response. My first reaction was : "Theo knows about this; problem solved" but unfortunately I'm not solving it! First, the column(s) is/are too narrow. I have been unable to see how i can set column width(s). Second, the column still insists on being ONE only. How can I get the listing to "bounce" into the next column when the bottom border is encountered? I had had ViewStyle set to vsList and have therefore tried vsReport as you suggested. I set Columns.Add and ViewStyle in the IDE : this should be OK shouldn't it? I want 5 columns at any time to display in the frame, but of course want to navigate using the horizontal scrollbar. I presume the property "columns" is referring to the number on display, not the total number required? Hope you can solve the above, then i can progress to the next problems................................ [My comments about the help box not appearing after entering "." were wrong; seems to work OK.] ---------------------------------------------------------------------- theo · 2009-08-03 07:47 Quote from: MikeFinch on August 03, 2009, 04:28:29 amFirst, the column(s) is/are too narrow. I have been unable to see how i can set column width(s). Please at least try to find out things on your own. When you added columns in the OI, wasn't there a column editor? Quote from: MikeFinch on August 03, 2009, 04:28:29 amSecond, the column still insists on being ONE only. How can I get the listing to "bounce" into the next column when the bottom border is encountered? I don't understand. You probably need a TStringGrid. ---------------------------------------------------------------------- MikeFinch · 2009-08-04 03:06 I do try (for hours) and I'm no fool. For the time being I'll throw in the towel : linux lazarus is obviously behind compared with Windows lazarus. I will just have to wait for the developers to "catchup"; only wish I had the competence to contribute, apart from picking the inadequacies! As I said before, the problems I have are not present in my Windows versions. Cheers! ---------------------------------------------------------------------- theo · 2009-08-04 08:14 Quote from: MikeFinch on August 04, 2009, 05:06:51 amlinux lazarus is obviously behind compared with Windows lazarus. I don't know what you're doing and I don't know what you want to do. But I can say that this code: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var li:TListItem; col:TListColumn; begin  ListView1.ViewStyle:=vsReport;  col:=ListView1.Columns.Add;  col.Caption:='Col1';  col.AutoSize:=true;  col:=ListView1.Columns.Add;  col.Caption:='Column2';  col.AutoSize:=true;  col:=ListView1.Columns.Add;  col.Caption:='C1';  col.AutoSize:=true;  li:=ListView1.Items.Add;  li.Caption:='test';  li.SubItems.Add('test1');  li.SubItems.Add('test2');  li:=ListView1.Items.Add;  li.Caption:='test';  li.SubItems.Add('test1');  li.SubItems.Add('test2');  li:=ListView1.Items.Add;  li.Caption:='test';  li.SubItems.Add('test1');  li.SubItems.Add('test2'); end; Produces the state in the attached image on GTK2 ---------------------------------------------------------------------- MikeFinch · 2009-08-06 02:40 Theo : I entered and ran your code (it certainly works) but before going further I think I should make it crystal clear what I am trying to do. In the Windows version (where I used ListBox successfully) I generate a long list of alphabetically sorted names; once the bottom of the listbox is encountered in column 1, the list continues in the second column (and so on). This continues until the list is finished. I display 5 columns at any one time and can use the horizontal scrollbar to navigate the list, or press a letter which will take me to the first name beginning with that letter. (however see my note in General Issues - Misc for a potential bug). [Question : will "Additional Options / Return to this topic" return me to this draft if I leave it? I've lost a composed message at least once by leaving - there's no save option or draft facility, is there?] Now you can see my aim you may wish to edit your code : can it be done for a continuing long list? ListBox ought to do it as I did in Windows. The problem is to get a list in column 1 to "bounce" into column 2 et cetera................... I don't need column headers of course. I have been assuming that the fact that ListBox doesn't work is simply that development hasn't progressed in linux at the same rate as in windows. Linux bugs are not being attended to at the same pace. Naturally I could be completely wrong. I noticed (yesterday) that the latest (0.9.27) linux version is 15 July, whereas windows seems to be updated daily. ---------------------------------------------------------------------- theo · 2009-08-06 08:34 Probably not supported on all platforms. But you can arrange your items in code.