Metoda ControlCollection.GetInlineShapeForControl —
Pobiera, podstawową InlineShape dla danej kontrolki.
Przestrzeń nazw: Microsoft.Office.Tools.Word
Zestaw: Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)
Składnia
'Deklaracja
Function GetInlineShapeForControl ( _
control As Control _
) As InlineShape
InlineShape GetInlineShapeForControl(
Control control
)
Parametry
- control
Typ: System.Windows.Forms.Control
Formant, w ControlCollection instancji, z którego chcesz się InlineShape.
Wartość zwracana
Typ: Microsoft.Office.Interop.Word.InlineShape
Znajdujące się poniżej InlineShape dla danej kontrolki.
Uwagi
Jeśli styl otaczania formantu nie ustawiono wartości Równo z tekstem, GetInlineShapeForControl metoda zwraca nullodwołanie o wartości null (Nothing w języku Visual Basic).
Przykłady
Poniższy przykład kodu dodaje Button do dokumentu tak, aby jego stylu zawijania jest równo z tekstem.Kod następnie wywołuje GetInlineShapeForControl metoda uzyskiwania położenie formantu z jego podstawowych InlineShape.
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());
}
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..