Tab into ListBox (SOLVED) lazarus / 39-Graphics ---------------------------------------------------------------------- xinyiman · 2010-10-19 11:43 var Lista_Prenotati: TListBox; Lista_Prenotati.Items.Add('hello' + ^I + 'world'); Why do I see the spacing correctly in Linux and in Windows I see a square?! How do I get the Tab spacing?! Does anyone know? ---------------------------------------------------------------------- BlueIcaro · 2010-10-19 11:46 What is ^I? Why a pointer? /BlueIcaro ---------------------------------------------------------------------- xinyiman · 2010-10-19 12:05 Because i serch the problem into delphi forum and solution are: ^I. I tested Chr(9) but result is not good! Help me please http://www.delphibasics.co.uk/RTL.asp?Name=Chr ---------------------------------------------------------------------- BlueIcaro · 2010-10-19 12:20 The space in AScci Table is 32, so try: Lista_Prenotati.Items.Add('hello' + #32 + 'world'); /BlueIcaro ---------------------------------------------------------------------- xinyiman · 2010-10-19 12:25 But I need the horizontal tab! Ascii code #9 but it does not work ---------------------------------------------------------------------- 99Percent · 2010-10-19 12:38 It might be related to UTF8/ASCII encoding. Try using different types of strings: AnsiString, ShortString, etc. ---------------------------------------------------------------------- xinyiman · 2010-10-19 13:00 I tested: string, ansistring, shortstring. Is not a solution! ---------------------------------------------------------------------- José Mejuto · 2010-10-19 17:46 Quote from: xinyiman on October 19, 2010, 01:43:03 pmvar Lista_Prenotati: TListBox; Lista_Prenotati.Items.Add('hello' + ^I + 'world'); Why do I see the spacing correctly in Linux and in Windows I see a square?! How do I get the Tab spacing?! Does anyone know? Hello, AFAIK Windows ListBox does not honor TAB character, or any other control character. All of them are rendered as a square box. This is windows behavior, not Lazarus decision. ---------------------------------------------------------------------- ivan17 · 2010-10-19 18:33 guys,  I don't mean to be rude, but if you don't understand what xinyiman asked, do not reply. the thing is, delphi listbox has a property called TabWidth. you set it to, say 200, then do something like: Code: [Select]LB.Items.Add('first column' + #9 + 'second column' + #9 + 'second column');  // #9 = tab LB.Items.Add('sdfasdf' + ^I + 'sd sdfsd' + ^I + 'sdf sadfasdf');  // sure, ^I works too LB.Items.Add('first column'#9'second column'#9'second column'); and you get the contents nicely aligned in three columns. you should fix tab width in OnResize event (200 units aren't 200 pixels, but you can easily find correspondence).  - - - - (explanation done, now the post answer)  - - - - lazarus listbox does not have that property because some widgetsets do not support it. sorry. make listbox ownerdrawn if you really need that option or use listview. i'd use stringgrid (hide the gridlines, add rowselect option and you're good). ---------------------------------------------------------------------- xinyiman · 2010-10-20 04:49 Make me an example please? ---------------------------------------------------------------------- ivan17 · 2010-10-20 09:22 Quote from: xinyiman on October 20, 2010, 06:49:34 amMake me an example please? well you could have been more specific, but i'll try to give you a good guess... throw a stringgrid onto an empty form; change these properties: Code: [Select]object Grid1: TStringGrid   Anchors = [akTop, akLeft, akRight, akBottom]   AutoAdvance = aaDown   ColCount = 2   FixedCols = 0   Flat = True   MouseWheelOption = mwGrid   Options = [goFixedVertLine, goFixedHorzLine, goColSizing,                       goRowSelect, goThumbTracking, goSmoothScroll]   RowCount = 11   ScrollBars = ssAutoVertical end now add these three methods: 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.Grid1HeaderSized(Sender: TObject; IsColumn: Boolean; Index: Integer);begin                                   {$HINTS OFF}  Grid1.ColWidths[1] := Grid1.ClientWidth - Grid1.ColWidths[0];end;                                    {$HINTS ON} procedure TForm1.Grid1Resize(Sender: TObject);begin  Grid1.ColWidths[0] := Grid1.ClientWidth - Grid1.ColWidths[1];end; procedure TForm1.FormCreate(Sender: TObject);begin  Grid1.Rows[0].Text := 'header1' + #13 + 'header2';  // both cells at onceend;  that should do it. try adding the grid lines and see if you prefer them. or alternate color. here's an example proc that will fill the grid a bit: 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  Grid1.RowCount := 16;  Grid1.Cols[1].Text := 'header2'#13'12'#13'23'#13'34'#13'45'#13'56'#13' 67'#13'78'#13'89'#13'90'#13'01'#13'12'#13'23'#13'34'#13'45'#13'56';  Grid1.Cells[0,15] := 'last row';  Grid1.Cells[0,1] := 'first row';end; ---------------------------------------------------------------------- xinyiman · 2010-10-20 10:36 Thank you!