CanAddPara.cs
- //
- // This code is part of Document Solutions for Word demos.
- // Copyright (c) MESCIUS inc. All rights reserved.
- //
- using System;
- using System.IO;
- using System.Drawing;
- using System.Collections.Generic;
- using System.Linq;
- using GrapeCity.Documents.Word;
-
- namespace DsWordWeb.Demos
- {
- // This example shows how to use ContentObject.CanAdd() method to test
- // whether a paragraph can be added to a content control.
- public class CanAddPara
- {
- public GcWordDocument CreateDocx()
- {
- var doc = new GcWordDocument();
- var p = doc.Body.Paragraphs.Add();
- var cc = p.AddContentControl(ContentControlType.RichText).Content;
- if (cc.CanAdd(typeof(Paragraph))) // returns false since the content control was created on inline level
- cc.AddParagraph("Paragraph added to Rich Text Content Control.");
- else
- cc.AddRun("Run added to Rich Text Content Control.");
- // Done:
- return doc;
- }
- }
- }
-