ColumnCount

TextFrameFormat.ColumnCount-Eigenschaft

Gibt die Anzahl der Spalten im Textbereich zurück oder legt sie fest. Dieser Wert muss eine positive Zahl sein. Andernfalls wird der Wert auf null gesetzt. Der Wert 0 bedeutet undefinierter Wert. Lese-/Schreibzugriff Int32.

public int ColumnCount { get; set; }

Beispiele

Der folgende Beispielcode zeigt, wie man Spalten in einen Textbereich innerhalb einer PowerPoint-Präsentation hinzufügt.

[C#]
string outPptxFileName = "ColumnsTest.pptx";
using (Presentation pres = new Presentation())
{
    IAutoShape shape1 = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300);
    TextFrameFormat format = (TextFrameFormat)shape1.TextFrame.TextFrameFormat;
    format.ColumnCount = 2;
    shape1.TextFrame.Text = "Alle diese Spalten sind gezwungen, innerhalb eines einzigen Textcontainers zu bleiben -- " +
                                "Sie können Text hinzufügen oder löschen - und der neue oder verbleibende Text passt " +
                                "sich automatisch an, um innerhalb des Containers zu bleiben. Sie können keinen Text " +
                                "von einem Container in einen anderen überlaufen lassen -- da die Spaltenoptionen von PowerPoint für Text eingeschränkt sind!";
    pres.Save(outPptxFileName, SaveFormat.Pptx);
    using (Presentation test = new Presentation(outPptxFileName))
    {
        Debug.Assert(2 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
        Debug.Assert(double.NaN == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
    }
    format.ColumnSpacing = 20;
    pres.Save(outPptxFileName, SaveFormat.Pptx);
    using (Presentation test = new Presentation(outPptxFileName))
    {
        Debug.Assert(2 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
        Debug.Assert(20 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
    }
    format.ColumnCount = 3;
    format.ColumnSpacing = 15;
    pres.Save(outPptxFileName, SaveFormat.Pptx);
    using (Presentation test = new Presentation(outPptxFileName))
    {
        Debug.Assert(3 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnCount);
        Debug.Assert(15 == ((AutoShape)test.Slides[0].Shapes[0]).TextFrame.TextFrameFormat.ColumnSpacing);
    }
}

Siehe auch