ShapeContainer.SelectNextShape 方法
依 ShapeCollection 的順序選取下一個或上一個圖形。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Public Function SelectNextShape ( _
shape As Shape, _
forward As Boolean, _
wrap As Boolean _
) As Boolean
public bool SelectNextShape(
Shape shape,
bool forward,
bool wrap
)
public:
bool SelectNextShape(
Shape^ shape,
bool forward,
bool wrap
)
member SelectNextShape :
shape:Shape *
forward:bool *
wrap:bool -> bool
public function SelectNextShape(
shape : Shape,
forward : boolean,
wrap : boolean
) : boolean
參數
shape
類型:Microsoft.VisualBasic.PowerPacks.Shape要開始搜尋的 Shape。
forward
類型:Booleantrue 表示在定位順序中向前移動,false 表示會向前移動。
wrap
類型:Booleantrue 表示會在到達最後一個圖案後,從定位順序中的第一個圖案繼續搜尋,否則為 false。
傳回值
類型:Boolean
如果圖形已啟用,則為 true,否則為 false。
備註
圖案加入至 ShapeCollection的命令取決於初始命令;您可以藉由呼叫 SetChildIndex 方法來變更命令。
範例
下列範例示範如何使用 GetNextShape 和 SelectNextShape 方法使用 TAB 鍵在表單的形狀間移動。 這個範例要求您的表單上必須有至少三個 RectangleShape 控制項。
Private Sub Shapes_PreviewKeyDown(
ByVal sender As Object,
ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs
) Handles RectangleShape1.PreviewKeyDown,
RectangleShape2.PreviewKeyDown,
RectangleShape3.PreviewKeyDown
Dim sh As Shape
' Check for the TAB key.
If e.KeyCode = Keys.Tab Then
' Find the next shape in the order.
sh = ShapeContainer1.GetNextShape(sender, True)
' Select the next shape.
ShapeContainer1.SelectNextShape(sender, True, True)
End If
End Sub
private void Shapes_PreviewKeyDown(object sender,
System.Windows.Forms.PreviewKeyDownEventArgs e)
{
Shape sh;
// Check for the TAB key.
if (e.KeyCode==Keys.Tab)
// Find the next shape in the order.
{
sh = shapeContainer1.GetNextShape((Shape) sender, true);
// Select the next shape.
shapeContainer1.SelectNextShape((Shape) sender, true, true);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)