Can't get Item's Text property lazarus / 31-LCL ---------------------------------------------------------------------- fafastrungen · 2011-02-28 19:49 Hi, I'm making an unit to translate applications made with Lazarus. I save in an ini file all captions, hints and text value and then I set them automatically using SetPropValue function. But before set properties values, I have to find them and I do it using GetPropList function. This is an example: Count := GetPropList(comboBox, PropList); This works perfectly, finds every combobox's property, but the next example does not work: Count := GetPropList(comboBox.Items, PropList); It return nothing, and the property ("Text") I have to set is owned by Items, not combobox. In short, what I need is to find the "Items.Text" property, not the "ComboBox.Text" property. Thanks in advance. ---------------------------------------------------------------------- DirkS · 2011-02-28 20:26 According to the docs GetPropList returns a list with published properties (http://www.freepascal.org/docs- html/rtl/typinfo/getproplist.html). TStrings (the type of 'Items') does not have any published props. Gr. Dirk. ---------------------------------------------------------------------- JuhaManninen · 2011-02-28 21:26 Quote from: fafastrungen on February 28, 2011, 08:49:53 pmHi, I'm making an unit to translate applications made with Lazarus. You mean translating the GUI texts? "resourcestring" is the way to go:  http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localization s_for_programs Juha ---------------------------------------------------------------------- fafastrungen · 2011-02-28 23:14 Thank you both, very helpful. ---------------------------------------------------------------------- fafastrungen · 2011-03-03 07:45 Is there a way to assign ComboBox.Items.Text property at run time ? I store in a xml file all properties I want to assign, for example: ...   ... I search for "comboBox" component, if I found it I search for "Items" property, if I found it I try to assign property using SetPropValue, but I can't assign it because "Items" has no published "Text" property, so how can I assign it ? ---------------------------------------------------------------------- JuhaManninen · 2011-03-03 09:31 Quote from: fafastrungen on March 03, 2011, 08:45:18 amIs there a way to assign ComboBox.Items.Text property at run time ? Like this:   ComboBox.Items.Text := MyText; which splits by newline automatically. The property does not need to be published to be assigned. Other ways to add items:   ComboBox.Items.Add(aString);   ComboBox.Items.Assign(aStringList); Juha ---------------------------------------------------------------------- fafastrungen · 2011-03-03 19:49 Quote Like this:   ComboBox.Items.Text := MyText; which splits by newline automatically. The property does not need to be published to be assigned. Other ways to add items:   ComboBox.Items.Add(aString);   ComboBox.Items.Assign(aStringList); Juha Hi, I know that, but my problem is that I assign at runtime all properties that I store in a xml file. For instance: ... ... I read every node's properties using a loop and try to assign them using SetPropValue. Something like this: var AttrName, AttrValue: String; XmlNode: TDomNode; Obj: TObject; begin  ReadXMLFile(XmlDoc, 'english.xml');     Node := XmlDoc.DocumentElement.FindNode('Form').FirstChild; // Form is control's parent  while Node <> nil do begin   for I := 1 to Node.Attributes.Length do begin   AttrName := Node.Attributes[I-1].NodeName;   AttrValue := AnsiToUtf8 (Node.Attributes[I-1].NodeValue);   Obj := FindComponent(Node.NodeName);   if Obj <> nil then SetPropValue(Obj, AttrName, AttrValue);  end;  Node := Node.NextSibling; end; This code is working but only with published properties, if in the xml file I store this: ...   ... I can't assign the property "text" of the "items" object because "text" is not published. I need a way to assign not-published-properties. Thanks. ---------------------------------------------------------------------- JuhaManninen · 2011-03-03 22:31 Quote from: fafastrungen on March 03, 2011, 08:49:17 pmI read every node's properties using a loop and try to assign them using SetPropValue. ComboBox.Items is published. You must "Add" or "Assign" elements to it. So, you need little more logic than just SetPropValue. The Lazarus form loader already loads a form's controls and their properties from a .lfm file. I think you are duplicating much of that functionality now. You could as well use .lfm form files, too. Juha ---------------------------------------------------------------------- DirkS · 2011-03-03 22:45 BTW: I don't think it makes much sense to fill the .Text property when it's for translation purposes. As already mentioned you should populate the list and then e.g. set .ItemIndex and let the system do the rest. Gr. Dirk. ---------------------------------------------------------------------- fafastrungen · 2011-03-04 00:08 QuoteThe Lazarus form loader already loads a form's controls and their properties from a .lfm file. I think you are duplicating much of that functionality now. You could as well use .lfm form files, too. Lazarus form loader use .lfm in compilation time, not in execution time. After I compile the app I have an .exe file only, so I want to translate the form at runtime. QuoteBTW: I don't think it makes much sense to fill the .Text property when it's for translation purposes. As already mentioned you should populate the list and then e.g. set .ItemIndex and let the system do the rest. Gr. Dirk. It's easier to set text property because I read data only one time and set data in one time, 2 actions to achieve the translation. If I populate the list I must use a loop, read each node in the xml file, read every item in the items property and set the text. I want a solution with minimum code. Of course, thanks to all for your help.