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:
...
<butonOk caption"Button" hint="this is a button" />
<labelInfo caption="Info about this" hint="This is a label" />
...
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:
...
<listBox>
<items text="Line 1\nLine 2\nLine 3" />
</listBox>
...
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.