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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.