ToolStripItem.MergeIndex 屬性

定義

取得或設定目前 ToolStrip 中已合併項目的位置。

public:
 property int MergeIndex { int get(); void set(int value); };
public int MergeIndex { get; set; }
member this.MergeIndex : int with get, set
Public Property MergeIndex As Integer

屬性值

整數,如有找到相符項目,表示已合併項目的索引;如果找不到相符項目,則為 -1。

範例

下列範例會 MergeIndex 使用 屬性,在特定位置插入合併 ToolStripMenuItem 的 。 此範例是類別概觀中較大範例的 ToolStripManager 一部分。

public void ShowInsertInSameLocationSample()
{
    // Notice how the items are in backward order.  
    // This is because "merge-one" gets applied, then a search occurs for the new second position 
    // for "merge-two", and so on.
    foreach (ToolStripItem item in cmsItemsToMerge.Items)
    {
        item.MergeAction = MergeAction.Insert;
        item.MergeIndex = 2;
    }
}
Public Sub ShowInsertInSameLocationSample()
   ' Notice how the items are in backward order.  
   ' This is because "merge-one" gets applied, then a search occurs for the new second position 
   ' for "merge-two", and so on.
   Dim item As ToolStripItem
   For Each item In  cmsItemsToMerge.Items
      item.MergeAction = MergeAction.Insert
      item.MergeIndex = 2
   Next item
End Sub

備註

MergeIndex使用 屬性來取得或設定 的 ToolStripMenuItem 索引,以便您可以存取它以進行功能表合併作業。

適用於