嘿我想知道通过插件填充多个行字段的方法是什么,我需要在多行字段中开始一个新行。 我的代码是:
foreach (Entity ent in allMyEnts.Entities)
{
//base_filesName is the multiple field need to be filled
//inside my loop
entityHoldsMultipleLineField.base_filesName =ent.base_name;
}
或者我应该创建一个数组并用循环填充我的字段? 什么是最好的方式?
答案 0 :(得分:1)
首先,你的代码中有Entity ent
的错误,因为你引用ent.base_name
- 这不会起作用,因为你将对象称为早期绑定的实体但是你在foreach
语句中将其转换为后期绑定。我会假设您打算使用后期限制作为我的答案(您可以根据需要将其更改为早期绑定。
就Dynamics和.NET而言,多行文本框仍然是string
。您可以使用StringBuilder
类轻松创建多行字符串,然后将结果string
(通过.ToString()
)添加到正确的字段中。
var multiLineStringResult = new StringBuilder();
foreach (Entity ent in allMyEnts.Entities)
{
//base_filesName is the multiple field need to be filled
//inside my loop
multiLineStringResult.AppendLine(ent.GetAttributeValue<string>("base_name"));
}
entityHoldsMultipleLineField["base_filesName"] = multiLineStringResult.ToString();