Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Extensions/ContextMenuStripExtensions.cs =================================================================== diff -u -rd3747e8b32bdedc478c8182bce75fba78269d34d -ra85e384df91356b2c2716591531a863e01da876b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Extensions/ContextMenuStripExtensions.cs (.../ContextMenuStripExtensions.cs) (revision d3747e8b32bdedc478c8182bce75fba78269d34d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Extensions/ContextMenuStripExtensions.cs (.../ContextMenuStripExtensions.cs) (revision a85e384df91356b2c2716591531a863e01da876b) @@ -20,27 +20,52 @@ /// The newly created . public static ToolStripItem AddMenuItem(this ContextMenuStrip parentMenu, string text, string tooltip, Image icon, EventHandler clickHandler) { + return parentMenu.InsertMenuItem(parentMenu.Items.Count, text, tooltip, icon, clickHandler); + } + + /// + /// Inserts a new with all standard parameters at the given . + /// + /// The position in the to add the item to. + /// The parent menu to which the new item is added. + /// Value for . + /// Value for . + /// Value for . + /// Method to handle the user clicking on the item.. + /// The newly created . + public static ToolStripItem InsertMenuItem(this ContextMenuStrip parentMenu, int position, string text, string tooltip, Image icon, EventHandler clickHandler) + { var newItem = new ToolStripMenuItem(text) { ToolTipText = tooltip, Image = icon }; newItem.Click += clickHandler; - parentMenu.Items.Add(newItem); + parentMenu.Items.Insert(position,newItem); return newItem; } /// - /// Adds a new with all standard parameters. + /// Adds a new . /// /// The parent menu to which the new item is added. public static void AddSeperator(this ContextMenuStrip parentMenu) { + parentMenu.InsertSeperator(parentMenu.Items.Count); + } + + /// + /// Insert a new at the given . + /// + /// The position in the to add the item to. + /// The parent menu to which the new item is added. + public static void InsertSeperator(this ContextMenuStrip parentMenu, int position) + { var newItem = new ToolStripSeparator(); - parentMenu.Items.Add(newItem); + parentMenu.Items.Insert(position, newItem); } } } \ No newline at end of file