Skip to content

Commit

Permalink
Port ListControlStringCollectionEditor
Browse files Browse the repository at this point in the history
Closes #1271
  • Loading branch information
vladimir-krestov authored and RussKie committed Nov 5, 2019
1 parent f93ffe5 commit 949bb34
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/System.Design/src/System.Design.Forwards.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 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.

using System.Runtime.CompilerServices;

[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageCollectionEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageIndexEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListControlStringCollectionEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringArrayEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringCollectionEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabPageCollectionEditor))]
3 changes: 3 additions & 0 deletions src/System.Windows.Forms.Design.Editors/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
<data name="ColorEditorSystemTab" xml:space="preserve">
<value>System</value>
</data>
<data name="DataSourceLocksItems" xml:space="preserve">
<value>Items collection cannot be modified when the DataSource property is set.</value>
</data>
<data name="DockEditorAccName" xml:space="preserve">
<value>Dock Picker</value>
</data>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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;

namespace System.Windows.Forms.Design
{
/// <summary>
/// The ListControlStringCollectionEditor override StringCollectionEditor
/// to prevent the string collection from being edited if a DataSource
/// has been set on the control.
/// </summary>
internal class ListControlStringCollectionEditor : StringCollectionEditor
{
public ListControlStringCollectionEditor(Type type) : base(type)
{
}

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
// If we're trying to edit the items in an object that has a DataSource set, throw an exception
ListControl control = context.Instance as ListControl;
if (control?.DataSource != null)
{
throw new ArgumentException(SR.DataSourceLocksItems);
}

return base.EditValue(context, provider, value);
}
}
}

0 comments on commit 949bb34

Please sign in to comment.