Share via


Metodo ControlCollection.GetInlineShapeForControl

Ottiene l'oggetto InlineShape sottostante per il controllo specificato.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Sintassi

'Dichiarazione
Function GetInlineShapeForControl ( _
    control As Control _
) As InlineShape
InlineShape GetInlineShapeForControl(
    Control control
)

Parametri

Valore restituito

Tipo: Microsoft.Office.Interop.Word.InlineShape
L'oggetto InlineShape sottostante per il controllo specificato.

Note

Se lo stile di ritorno a capo del controllo non è impostato su In linea con il testo, il metodo GetInlineShapeForControl restituisce nullriferimento null (Nothing in Visual Basic).

Esempi

Nell'esempio di codice seguente viene aggiunto un oggetto Button al documento in modo che lo stile di ritorno a capo sia in linea con il testo.Il codice richiama quindi il metodo GetInlineShapeForControl per ottenere la posizione del controllo dall'oggetto InlineShape sottostante.

Private Sub WordGetInlineShape()
    Dim testButton As Microsoft.Office.Tools.Word.Controls.Button = _
        Me.Controls.AddButton(Me.Paragraphs(1).Range, 50, 25, "testButton")

    Dim buttonShape As Microsoft.Office.Interop.Word.InlineShape = _
            Me.Controls.GetInlineShapeForControl(testButton)

    If buttonShape IsNot Nothing Then
        MessageBox.Show("The following properties can be cached in the" & _
            vbCrLf & "document to enable you to recreate the control:" _
            & vbCrLf & vbCrLf & "Range: position " & _
            buttonShape.Range.Start.ToString _
            & " through " & buttonShape.Range.End.ToString _
            & vbCrLf & "Width: " & buttonShape.Width.ToString _
            & vbCrLf & "Height: " & buttonShape.Height.ToString)
    End If
End Sub
private void WordGetInlineShape()
{
    Microsoft.Office.Tools.Word.Controls.Button testButton =
        this.Controls.AddButton(this.Paragraphs[1].Range, 50, 25,
        "testButton");

    Microsoft.Office.Interop.Word.InlineShape buttonShape =
        this.Controls.GetInlineShapeForControl(testButton);

    if (buttonShape != null)
    {
        MessageBox.Show("The following properties can be cached in the" +
            "\n" + "document to enable you to recreate the control:"
            + "\n\n" + "Range: position " + buttonShape.Range.Start.
            ToString() + "through " + buttonShape.Range.End.ToString()
            + "\n" + "Width: " + buttonShape.Width.ToString() + "\n" +
            "Height: " + buttonShape.Height.ToString());
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ControlCollection Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Word