ControlCollection.GetInlineShapeForControl 方法
取得指定之控制項的基礎 InlineShape。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)
語法
'宣告
Function GetInlineShapeForControl ( _
control As Control _
) As InlineShape
InlineShape GetInlineShapeForControl(
Control control
)
參數
- control
型別:System.Windows.Forms.Control
您要透過 ControlCollection 執行個體,取得 InlineShape 的控制項。
傳回值
型別:Microsoft.Office.Interop.Word.InlineShape
指定之控制項的基礎 InlineShape。
備註
如果控制項的換行樣式不是設為 [與文字排列],GetInlineShapeForControl 方法便會傳回 nullNull 參照 (即 Visual Basic 中的 Nothing)。
範例
下列程式碼會將 Button 加入至文件,使它的換行樣式為與文字排列。 接著這個程式碼會呼叫 GetInlineShapeForControl 方法,從這個控制項的基礎 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());
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。