CommentCollection

CommentCollection class

提供对集合的类型访问Comment节点.

要了解更多信息,请访问使用评论文档文章。

public class CommentCollection : NodeCollection

特性

姓名描述
Count { get; }获取集合中的节点数。
Item { get; }检索Comment在给定的索引处。 (2 indexers)

方法

姓名描述
Add(Node)在集合末尾添加一个节点。
Clear()从此集合和文档中删除所有节点。
Contains(Node)确定节点是否在集合中。
GetEnumerator()提供对节点集合的简单“foreach”样式迭代。
IndexOf(Node)返回指定节点的从零开始的索引。
Insert(int, Node)将节点插入到指定索引的集合中。
Remove(Node)从集合和文档中删除节点。
RemoveAt(int)从集合和文档中删除指定索引处的节点。
ToArray()将集合中的所有节点复制到新的节点数组。

例子

展示如何将评论标记为“完成”。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Helo world!");

 // 插入注释以指出错误。
Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now);
comment.SetText("Fix the spelling error!");
doc.FirstSection.Body.FirstParagraph.AppendChild(comment);

 // 注释有一个“完成”标志,默认设置为“false”。
// 如果有评论建议我们在文档中做出更改,
// 我们可以应用更改,然后设置“完成”标志来指示更正。
Assert.False(comment.Done);

doc.FirstSection.Body.FirstParagraph.Runs[0].Text = "Hello world!";
comment.Done = true;

// 已完成的评论将自我区分
// 来自那些没有“完成”且带有褪色文本颜色的。
comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now);
comment.SetText("Add text to this paragraph.");
builder.CurrentParagraph.AppendChild(comment);

doc.Save(ArtifactsDir + "Comment.Done.docx");

也可以看看