Forum > WinCE
Can't show a TstringList to a combo box
donnie:
I have added some items to a StringList.The items are loaded normal(I write them to a log file).
But when I add them to my combo box (and built it for my PDA)
for i := 0 to mainform.countStringList-1 do
begin
combobox.items.add(mainform.TStringList[i]);
end;
the combo box is empty.
Does anyone know how to fix it and show them in the same language with my TstringList?
felipemdc:
Looks like your file isn't encoded in UTF-8, you can either encode the file in UTF-8 or convert upon loading, here a simple idea:
for i := 0 to mainform.countStringList-1 do
begin
combobox.items.add(AnsiToUTF8(mainform.TStringList));
end;
There are better routines for conversion in Lazarus, but I don't remember the unit name or the routine names =D Should be easy to find searching Lazarus sources.
Lazarus controls always require the strings to be UTF-8 encoded
jagorath:
You can also use the TStrings.Assign method -
--- Code: ---combobox.items.Assign(mainform.TStringList);
--- End code ---
donnie:
It does work now in windows but still not in my PDA.The AnsiToUtf8 works fine in windows( to work the Assign() must be encoded to utf8 first with AnsiToUtf8).To my PDA with AnsiToUtf8 it shows me something but the letters are like...chinese.The English letters are ok!But the others(Greek) are not(Maybe doesn't support Greek???)!Thank you very much both.You've been very helpful!
Zoran:
--- Quote from: nek on March 09, 2010, 08:19:03 am ---It does work now in windows but still not in my PDA.The AnsiToUtf8 works fine in windows( to work the Assign() must be encoded to utf8 first with AnsiToUtf8).To my PDA with AnsiToUtf8 it shows me something but the letters are like...chinese.The English letters are ok!But the others(Greek) are not(Maybe doesn't support Greek???)!Thank you very much both.You've been very helpful!
--- End quote ---
No, no, no. UTF8 certanly does support Greek, only AnsiToUTF8 does not know that your file uses greek code page! If you know that your file will always be Greek, then here is what you should do:
First, add LConvEncoding unit to uses list.
Then, instead of AnsiToUTF8, use CP1253ToUTF8 (Greek is probably encoded with Win1253 code page).
So, this should work for you:
--- Code: ---combobox.items.add(CP1253ToUTF8(mainform.TStringList));
--- End code ---
Navigation
[0] Message Index
[#] Next page