-3

I have a simple form containing TstringGrid with 2 columns, a TStringColumn and TCheckColumn added. I have seen many examples of saving the contents to file if the cells contain text or numbers. I have not seen any examples of saving with a TCheckColumn. I am assuming that I must check each CheckColumn cell, determine its state and assign a value that can be saved to file. Or maybe there is a more elegant way to do this.

As for sorting - again many examples using strings or numbers but none with TCheckColumn. I have HeaderClick enabled. On the TStringColumn I would like to sort Alphabetically - On the TCheckColumn - I would like checked items at the top of the column.

I am using Delphi 10.2.1 and will compile for Android.

WobblyBob
  • 109
  • 1
  • 12
  • Please, *one* question per post. – Tom Brunberg Oct 28 '17 at 03:03
  • Thanks Tom - Should I re-submit as separate Q's or wait for responses - I was not aware of the one question per post rule :( – WobblyBob Oct 28 '17 at 06:02
  • 1
    As nobody has yet answered this post, leave file save/load but remove sorting and post it as a new question. Please then read [**Asking**](http://stackoverflow.com/help/asking) to learn what you can ask about and how to present your question, especially [**How do I ask a good question**](https://stackoverflow.com/help/how-to-ask), and all linked docs. Pay attention to describing or showing code for what you have tried already and explain why it didn't work for you. – Tom Brunberg Oct 28 '17 at 07:01
  • For editing see the "edit" button right under the tags – Tom Brunberg Oct 28 '17 at 07:05
  • 1
    Maybe I wasn't clear enough, so I repeat: **remove the question regarding sorting and post it as a new question**. Or did you not yet read the links I provided, where it is explained? – Tom Brunberg Oct 28 '17 at 13:22
  • Your question is not only the title, it's ***the whole question***: title **and** body. So take note of @Tom 's advice and fix your ***whole*** question. – Disillusioned Oct 28 '17 at 23:58

1 Answers1

0

Without saying you shouldn't start from here - I will just answer the specific questioN; To keep it simple, I would: Save: iterate through the rows and take the state of the checkboxes and prefix the string item with BoolToStr(theCheckValue)+':'+theContents of the string. Then save the stringList.

To Load: load into the stringList and then iterate and break the string apart using pos on the ':' and StrToBool the left portion, setting the checked item based on this. Not got an IDE up, so haven't tested, but that would be my approach as a bit of a hack.

Jason Chapman
  • 88
  • 1
  • 5