DocumentBase.StyleSortMethod 属性

定义

获取或设置一个值,该值指定在对“样式”任务窗格中的样式进行排序时使用的排序方法。

public Microsoft.Office.Interop.Word.WdStyleSort StyleSortMethod { get; set; }

属性值

WdStyleSort

WdStyleSort 值之一。

示例

下面的代码示例显示 "样式" 任务窗格的当前排序方法。 接下来,如果当前排序方法不是字母排序方法,则代码将显示一条消息,告知用户要修改 sort 方法,然后将 sort 方法修改为字母排序顺序。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void SetStyleSortOrder()
{
    MessageBox.Show("Current sort method for the styles task pane is: " 
        + this.StyleSortMethod.ToString());
    if (this.StyleSortMethod != Word.WdStyleSort.wdStyleSortByName)
    {
        MessageBox.Show("Changing sort method to "
            + Word.WdStyleSort.wdStyleSortByName.ToString()
            + " to sort styles alphabetically in the styles "
            + "task pane.");
        this.StyleSortMethod = Word.WdStyleSort.wdStyleSortByName;
    }            
}
Private Sub SetStyleSortOrder()
    MessageBox.Show("Current sort method for the styles task pane is: " _
            + Me.StyleSortMethod.ToString())
    If Me.StyleSortMethod <> Word.WdStyleSort.wdStyleSortByName Then
        MessageBox.Show("Changing sort method to " _
            + Word.WdStyleSort.wdStyleSortByName.ToString() _
            + " to sort styles alphabetically in the styles " _
            + "task pane.")
        Me.StyleSortMethod = Word.WdStyleSort.wdStyleSortByName
    End If
End Sub

适用于