Share via


DocumentBase.StyleSortMethod Property

Definition

Gets or sets a value that specifies the sort method to use when sorting styles in the Styles task pane.

public:
 property Microsoft::Office::Interop::Word::WdStyleSort StyleSortMethod { Microsoft::Office::Interop::Word::WdStyleSort get(); void set(Microsoft::Office::Interop::Word::WdStyleSort value); };
public Microsoft.Office.Interop.Word.WdStyleSort StyleSortMethod { get; set; }
member this.StyleSortMethod : Microsoft.Office.Interop.Word.WdStyleSort with get, set
Public Property StyleSortMethod As WdStyleSort

Property Value

One of the WdStyleSort values.

Examples

The following code example displays the current sort method for the Styles task pane. Next, if the current sort method is not the alphabetical sort method, the code displays a message that informs the user that the sort method is about to be modified, and then modifies the sort method to the alphabetical sort order. To use this example, run it from the ThisDocument class in a document-level project.

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

Applies to