[SOLVED] TStringgrid at runtime *Thanks* lazarus / 31-LCL ---------------------------------------------------------------------- guywest · 2020-03-15 13:20 Good day, Yesterday I spent almost a whole afternoon to get TStringgrid to do what I want (which works very easy and well in Delphi but not in Lazarus 2.0.2. I want to create a grid on a form at runtime. Several code examples found, nothing works. Example: 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 MyGrid := TStringGrid.Create(Self);  MyGrid.Parent := Self;  MyGrid.Visible := true;  MyGrid.left := 20;  MyGrid.top := 20;  MyGrid.rowcount := 5;  MyGrid.colcount := 5;  MyGrid.width := 100;  MyGrid.height := 100;  MyGrid.Enabled := true;  MyGrid.cells[1, 1] := 'hi';  NOTHING visible on the form. Changing parent to form name or create on form name in stead of Self does not change anything: always empty form. Tried also with an empty grid at design time and then changing rows and columns (yes: with the columns.add, not by only changing colcount) at runtime but changes are not visible: the design time version is always displayed. No refresh, repaint, invalidate, ... helps. Why does this not work? As the stringgrid works very easily under Delphi but is a REAL pain in the ass in Lazarus (a lot of stupid error messages in other applications also), I really think the Stringgrid component of Lazarus really sucks. I'm a wrong? Is there an important item that I don't know to make the Stringgrid of Lazarus work as easily as the Stringgrid of Delphi? Thanks! ---------------------------------------------------------------------- Bart · 2020-03-15 13:24 Self is the form you try to place it on? Bart ---------------------------------------------------------------------- jamie · 2020-03-15 13:50 This works for me.... 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  G:TstringGrid;begin  G :=TStringGrid.Create(Self);  G.Parent := Self;  With G do   Begin     Bounds(0,0,200,300);     Enabled := True;     Cells[1,1] := 'Hi';   end;end; ---------------------------------------------------------------------- wp · 2020-03-15 14:24 Quote from: guywest on March 15, 2020, 02:20:12 pmTStringgrid to do what I want (which works very easy and well in Delphi but not in Lazarus 2.0.2. [...] Several code examples found, nothing works. [...] NOTHING visible on the form. Are you sure that your code is really called? The code itself is correct and works if called for example from a button OnClick event handler. In fact, the Lazarus StringGrid is much superior to that of Delphi, if offers many features for which the Delphi grid requires a third-party grid. ---------------------------------------------------------------------- RAW · 2020-03-15 16:30 QuoteThis works for me....ME TOO ... ---------------------------------------------------------------------- winni · 2020-03-15 18:55 Hi! Yes - works with no problem. But RAW: nobody talked about ClLIME! Outsch! Winni ---------------------------------------------------------------------- RAW · 2020-03-15 20:10 I fell into the clLime-Potion when I was a little boy ... ---------------------------------------------------------------------- guywest · 2020-03-21 16:37 Thanks to you all. The code of Jamie works. VERY strange. ---------------------------------------------------------------------- guywest · 2020-03-21 16:38 Quote from: wp on March 15, 2020, 03:24:06 pmQuote from: guywest on March 15, 2020, 02:20:12 pmTStringgrid to do what I want (which works very easy and well in Delphi but not in Lazarus 2.0.2. [...] Several code examples found, nothing works. [...] NOTHING visible on the form. Are you sure that your code is really called? The code itself is correct and works if called for example from a button OnClick event handler. In fact, the Lazarus StringGrid is much superior to that of Delphi, if offers many features for which the Delphi grid requires a third-party grid. Is possible but with Delphi Grid I sometimes had an error, with the Lazarus Grid it RAINS errors. ---------------------------------------------------------------------- jamie · 2020-03-21 19:08 I think Bart was on the correct path, where does "SELF" come from?