diff --git a/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs new file mode 100644 index 00000000000..460d6c0083a --- /dev/null +++ b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel.Design; +using System.Diagnostics; + +namespace System.Windows.Forms.Design +{ + /// + /// Main class for collection editor for . + /// Allows a single level of children to be designed. + /// + internal class TabPageCollectionEditor : CollectionEditor + { + public TabPageCollectionEditor() : base(typeof(TabControl.TabPageCollection)) + { + } + + /// + /// Sets the specified collection to have the specified array of items. + /// + protected override object SetItems(object editValue, object[] value) + { + var tabControl = Context.Instance as TabControl; + tabControl?.SuspendLayout(); + + object retValue = base.SetItems(editValue, value); + + tabControl?.ResumeLayout(); + return retValue; + } + + protected override object CreateInstance(Type itemType) + { + object instance = base.CreateInstance(itemType); + + TabPage tabPage = instance as TabPage; + Debug.Assert(tabPage != null); + tabPage.UseVisualStyleBackColor = true; + + return tabPage; + } + } +} diff --git a/src/System.Windows.Forms.Design.Editors/tests/UnitTests/EnsureEditorsTests.cs b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/EnsureEditorsTests.cs index 91087f96960..d886ea19fcf 100644 --- a/src/System.Windows.Forms.Design.Editors/tests/UnitTests/EnsureEditorsTests.cs +++ b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/EnsureEditorsTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -95,7 +95,7 @@ public void EnsureUITypeEditorForType(Type type, Type expectedEditorType) //[InlineData(typeof(MaskedTextBox), "Text", typeof(MaskedTextBoxTextEditor))] [InlineData(typeof(NotifyIcon), "BalloonTipText", typeof(MultilineStringEditor))] [InlineData(typeof(NotifyIcon), "Text", typeof(MultilineStringEditor))] - //[InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))] + [InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))] [InlineData(typeof(TabPage), "ImageIndex", typeof(ImageIndexEditor))] [InlineData(typeof(TabPage), "ImageKey", typeof(ImageIndexEditor))] //[InlineData(typeof(TextBox), "AutoCompleteCustomSource", typeof(ListControlStringCollectionEditor))]