Setting StringGrid Columns Property Kills Data Load Process lazarus / 10-Designer ---------------------------------------------------------------------- flywire · 2015-03-14 11:34 I am working on this form: http://forum.lazarus.freepascal.org/index.p hp/topic,27663.msg171291.html#msg171291 which is basically just a simple TStringGrid with the program in the post below it. When I change the StringGrid Columns Property and add StringGrid.Columns properties the data load process generates an error and will not run. Any thoughts? Is is simply that the Column Title is different to the (numeric) Column Title assigned in the program? ---------------------------------------------------------------------- Blaazen · 2015-03-14 12:13 There should be no difference in normal/Columns approach if you access the cells with Cell[x, y];. Title cells are normal cells, only they can have their own font-setting or image. You can remove them by setting FixedRows:=0;. What error message you got? ---------------------------------------------------------------------- flywire · 2015-03-14 12:20 After adding just one column the title becomes Title and the Error message is "Use Columns property to add/remove columns." OK/Cancel etc. Object Inspector, StringGrid1, Properties, Columns ... Add, close down, compile, run - error. Maybe I set it to a single column so that the program can't process all of the columns? I wouldn't have thought so though. ---------------------------------------------------------------------- Blaazen · 2015-03-14 12:36 Now I see. When you use columns, you cannot simply change property ColCount of the grid. You have to add/delete columns from collection, i.e.: Instead of Code: [Select]ColCount:=ColCount+1;use Code: [Select]Columns.Add;And similar for delete, insert, move, exchange etc. ---------------------------------------------------------------------- flywire · 2015-03-14 12:45 I am not quite clear. The code works until I change the column properties and if I delete the property then the code works again. What exactly happens when I set columns through the Object Inspector? Are you saying that when I use Columns in the Object Inspector to set Columns then I need to change the code? I assume that this setting disables the methodology used in the code to add columns. Can I just make sure that the number of columns match? Is there a better way to set column labels, visibility etc? ---------------------------------------------------------------------- flywire · 2015-03-14 12:58 OK I replace Code: [Select]StringGrid1.ColCount := 42 + 1; with Code: [Select]Columns.Add;inside the loop. ---------------------------------------------------------------------- Blaazen · 2015-03-14 13:59 When you start to use Columns, property ColCount become "readonly". You can also read Columns.Count. Once you use Columns, you are allowed to change number of columns only via Columns.Add, Columns.Delete, Columns.Insert or Columns.Clear. ---------------------------------------------------------------------- flywire · 2015-03-14 20:40 Quote from: Blaazen on March 14, 2015, 02:59:00 pmWhen you start to use Columns, property ColCount become "readonly". ... Ahhh ... as long as I don't write ColCount in code then it should be fine. Easy fix. edit: typo. ---------------------------------------------------------------------- flywire · 2015-03-15 06:46 OK I replaced Code: [Select]StringGrid1.ColCount := 42 + 1; with Code: [Select]// StringGrid1.ColCount := 42 + 1; done.