/// <summary> /// Inserts drag&drop item at specified position. /// </summary> /// <param name="containerItem">Container item.</param> /// <param name="objItem">Item being inserted</param> /// <param name="iPos">Insertion position</param> /// <param name="Before">Indicates whether item is inserted before the specified insertion position</param> public static void InsertItemAt(BaseItem containerItem, BaseItem objItem, int iPos, bool Before) { if(containerItem.ExpandedItem()!=null) { containerItem.ExpandedItem().Expanded=false; } if(!Before) { if(iPos+1>=containerItem.SubItems.Count) { containerItem.SubItems.Add(objItem,GetAppendPosition(containerItem)); } else { containerItem.SubItems.Add(objItem,iPos+1); } } else { if(iPos>=containerItem.SubItems.Count) { containerItem.SubItems.Add(objItem, GetAppendPosition(containerItem)); } else { containerItem.SubItems.Add(objItem,iPos); } } if(containerItem.ContainerControl is Bar) ((Bar)containerItem.ContainerControl).RecalcLayout(); else if(containerItem.ContainerControl is MenuPanel) ((MenuPanel)containerItem.ContainerControl).RecalcSize(); else if(containerItem.ContainerControl is BarBaseControl) ((BarBaseControl)containerItem.ContainerControl).RecalcLayout(); else if(containerItem.ContainerControl is ItemControl) ((ItemControl)containerItem.ContainerControl).RecalcLayout(); else { containerItem.RecalcSize(); containerItem.Refresh(); } }