ToolStripItem.MergeIndex ToolStripItem.MergeIndex ToolStripItem.MergeIndex ToolStripItem.MergeIndex Property

定义

获取或设置合并的项在当前 ToolStrip 内的位置。Gets or sets the position of a merged item within the current 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。An integer representing the index of the merged item, if a match is found, or -1 if a match is not found.

示例

下面的示例使用MergeIndex属性将合并ToolStripMenuItem插入特定位置。The following example uses the MergeIndex property to insert a merged ToolStripMenuItem in a specific location. 此示例是ToolStripManager类概述中提供的一个更大示例的一部分。This example is part of a larger example available in the ToolStripManager class overview.

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

注解

使用属性可获取或设置的ToolStripMenuItem索引, 以便您可以访问它以用于菜单合并操作。 MergeIndexUse the MergeIndex property to get or set the index of a ToolStripMenuItem so that you can access it for menu-merging operations.

适用于