/// <inheritdoc/> public override void Invoke() { Dictionary <int, int> groups = new Dictionary <int, int>(); // collect used group indices ObjectCollection allObjects = ActiveReport.AllObjects; foreach (Base c in Designer.Objects) { if (c is ComponentBase) { int index = (c as ComponentBase).GroupIndex; if (!groups.ContainsKey(index)) { groups.Add(index, 0); } } } // find index that not in use int groupIndex; for (groupIndex = 1; ; groupIndex++) { if (!groups.ContainsKey(groupIndex)) { break; } } foreach (Base c in SelectedObjects) { ComponentBase obj = c as ComponentBase; if (obj != null && obj.HasFlag(Flags.CanGroup)) { obj.GroupIndex = groupIndex; } } }