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以便你可以访问它进行菜单合并操作。

适用于