Skip to content

Commit e0d025c

Browse files
Zachary DanzRussKie
authored andcommitted
Port TabPageCollectionEditor
Closes #1281
1 parent 625922e commit e0d025c

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

src/System.Design/src/System.Design.Forwards.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageIndexEditor))]
1010
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringArrayEditor))]
1111
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringCollectionEditor))]
12+
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabPageCollectionEditor))]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.ComponentModel.Design;
6+
using System.Diagnostics;
7+
8+
namespace System.Windows.Forms.Design
9+
{
10+
/// <summary>
11+
/// Main class for collection editor for <see cref="TabControl.TabPageCollection"/>.
12+
/// Allows a single level of <see cref="ToolStripItem"/> children to be designed.
13+
/// </summary>
14+
internal class TabPageCollectionEditor : CollectionEditor
15+
{
16+
public TabPageCollectionEditor() : base(typeof(TabControl.TabPageCollection))
17+
{
18+
}
19+
20+
/// <summary>
21+
/// Sets the specified collection to have the specified array of items.
22+
/// </summary>
23+
protected override object SetItems(object editValue, object[] value)
24+
{
25+
var tabControl = Context.Instance as TabControl;
26+
tabControl?.SuspendLayout();
27+
28+
object retValue = base.SetItems(editValue, value);
29+
30+
tabControl?.ResumeLayout();
31+
return retValue;
32+
}
33+
34+
protected override object CreateInstance(Type itemType)
35+
{
36+
object instance = base.CreateInstance(itemType);
37+
38+
TabPage tabPage = instance as TabPage;
39+
Debug.Assert(tabPage != null);
40+
tabPage.UseVisualStyleBackColor = true;
41+
42+
return tabPage;
43+
}
44+
}
45+
}

src/System.Windows.Forms.Design.Editors/tests/UnitTests/EnsureEditorsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -96,7 +96,7 @@ public void EnsureUITypeEditorForType(Type type, Type expectedEditorType)
9696
//[InlineData(typeof(MaskedTextBox), "Text", typeof(MaskedTextBoxTextEditor))]
9797
[InlineData(typeof(NotifyIcon), "BalloonTipText", typeof(MultilineStringEditor))]
9898
[InlineData(typeof(NotifyIcon), "Text", typeof(MultilineStringEditor))]
99-
//[InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))]
99+
[InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))]
100100
[InlineData(typeof(TabPage), "ImageIndex", typeof(ImageIndexEditor))]
101101
[InlineData(typeof(TabPage), "ImageKey", typeof(ImageIndexEditor))]
102102
//[InlineData(typeof(TextBox), "AutoCompleteCustomSource", typeof(ListControlStringCollectionEditor))]

0 commit comments

Comments
 (0)