I insert this object in the text:
obj := TWPObjectField.Create(Editor);
obj.FieldName := 'LICENTIE';
obj.Name:='LI';
Editor.TextObjects.Insert(obj);
That works fine.
Then I want to see if that TextObject is inserted in the text with this:
with Editor3.TextObjects do
begin
if FindName('LICENTIE')=nil then ShowMessage('found!');
end;
But it does not find the field. What am I doing wrong?
<--->
I tried, but FindName does not work.
I made this function and it works OK.
function
FindFieldName(WPEditor:TWPRichText;aFieldName:string):TWPObjectField;
var
t1 :integer;
begin
Result:=nil;
if WPEditor.TextObjects.Count>0 then
begin
for t1:=0 to WPEditor.TextObjects.Count-1 do if
SameText(TWPObjectField(WPEditor.TextObjects.List
[t1]).FieldName,aFieldName) then
Result:=TWPObjectField(WPEditor.TextObjects.List[t1]);
end;
end;