TstringGrid Cells Data Entry lazarus / 61-Beginners ---------------------------------------------------------------------- JLWest · 2019-01-19 17:38 Trying to add a row and populate with data. The TStringGrid has 1 fixed Column and 1 fixed Row. It has 0 custom rows at startup. Therefor; I add a row get a row count subtract 1 and I'm trying to place an item into Cells(0,1) i.e. Cells[Col,Row]:= IntToStr(aIdx);  Under the debugger Lines 10, 11 and 12 set Col and Rows and at Line 13 Col = 0, Row = 1.  The aIdx is loaded; however it's in row 1 and column 1. Not in the fixed Column. The cemented line 15 works perfectly. I missing something somewhere. 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 TbtnPath.LoadG1300Grid(aIdx  : Integer;                                aRCId : String;                                  aLine : String);  Var   i   : Integer = 0;   Row : Integer = 0;   Col : Integer = 0; Begin  G1300Grid.RowCount := G1300Grid.RowCount +1;   // Add a new row   Row := G1300Grid.RowCount;                                 // Get Row Count = 2  Dec(Row);                                                           // Zero Base so Dec to 1  Col := 0;  with G1300Grid do begin    Cells[Col,Row]:= IntToStr(aIdx); // Cells[0,1] := '0,1';  end; end; ---------------------------------------------------------------------- HeavyUser · 2019-01-19 18:05 Quote from: JLWest on January 19, 2019, 06:38:54 pmTrying to add a row and populate with data. The TStringGrid has 1 fixed Column and 1 fixed Row. It has 0 custom rows at startup. Therefor; I add a row get a row count subtract 1 and I'm trying to place an item into Cells(0,1) i.e. Cells[Col,Row]:= IntToStr(aIdx);  Under the debugger Lines 10, 11 and 12 set Col and Rows and at Line 13 Col = 0, Row = 1.  The aIdx is loaded; however it's in row 1 and column 1. Not in the fixed Column. The cemented line 15 works perfectly. I missing something somewhere. 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 TbtnPath.LoadG1300Grid(aIdx  : Integer;                                aRCId : String;                                  aLine : String);  Var   i   : Integer = 0;   Row : Integer = 0;   Col : Integer = 0; Begin  G1300Grid.RowCount := G1300Grid.RowCount +1;   // Add a new row   Row := G1300Grid.RowCount;                                 // Get Row Count = 2  Dec(Row);                                                           // Zero Base so Dec to 1  Col := 0;  with G1300Grid do begin    Cells[Col,Row]:= IntToStr(aIdx); // Cells[0,1] := '0,1';  end; end;  using the "with" construct you instruct the compiler to give priority to the G1300Grid properties over everything else. Since the TStringGrid already has properties named Col and Row you end up using the grids properties instead of the local variables defined in your procedure. If I recall correctly there was a member that was advocating the use of v in the local variable names to avoid this kind of situations can't recall who was though sorry. In short rename your local variable to avoid the conflict (or stop using with) and everything should work eg. 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 TbtnPath.LoadG1300Grid(aIdx  : Integer;                                aRCId : String;                                  aLine : String);  Var   i   : Integer = 0;   vRow : Integer = 0;   vCol : Integer = 0; Begin  G1300Grid.RowCount := G1300Grid.RowCount +1;   // Add a new row   vRow := G1300Grid.RowCount;                               // Get Row Count = 2  Dec(vRow);                                                         // Zero Base so Dec to 1  vCol := 0;  with G1300Grid do begin    Cells[vCol,vRow]:= IntToStr(aIdx); // Cells[0,1] := '0,1';  end; end; ---------------------------------------------------------------------- jamie · 2019-01-19 18:08 You fast, I was in the middle of replying ! ---------------------------------------------------------------------- JLWest · 2019-01-19 18:19 WOW! I would never have figured that one out. That's pretty deep into the woods. And for a beginner or a limited knowledge pascal user such as me the answer might as well been on the moon under a rock. Changed to vRow and vCol and It's works great.  Thank You ---------------------------------------------------------------------- HeavyUser · 2019-01-19 18:48 Quote from: JLWest on January 19, 2019, 07:19:57 pmWOW! I would never have figured that one out. That's pretty deep into the woods. And for a beginner or a limited knowledge pascal user such as me the answer might as well been on the moon under a rock. Changed to vRow and vCol and It's works great.  Thank You You can test for this situation easily. just ctrl+click on the variable name, at the line you have the problem, if the editor jumps to the declaration of the variable you expect, then the problem is elsewhere, if not, then you have a conflict that needs intervention to be resolved. ---------------------------------------------------------------------- JLWest · 2019-01-19 19:50 @HeavyUser Just tested that Clt+Click. Poped up on the list. So that wold tell me I have a conflict or not using the variable I think I'm using? I thought the local variable had the scope. Not to sure that I would have associate that with the problem. Maybe. But maybe this is something different than scope. Sounds like inherited class properties. Thanks for tip ---------------------------------------------------------------------- jamie · 2019-01-19 22:57 its not the variable, its just the NAME, the "WITH" puts all identifiers in the StringGrid that are visible first. if it does not find a matching identifier of that name in the StringGrid then it moves back one and that would be the level you were expecting.  You can also specify multiple scopes too but they need to be of different types otherwise you'll only see the last one, for example.  With Button1, Button2, Button3 do   Begin      //  if all these buttons are of the same class type and you specify a identifier of this class      // you'll only see the identifiers of BUtton3  End;  I am not even sure if the compiler will allow this, in reality it shouldn't..  but you can use this for different types of objects  or simply not use that construct at all! ---------------------------------------------------------------------- JLWest · 2019-01-20 03:35 Thanks