Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting System.Windows.Forms.Design.ListControlStringCollectionEditor #2078

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/System.Design/src/System.Design.Forwards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 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.ListControlStringCollectionEditor))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need StringCollectionEditor and ArrayEditor...

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);
}
}
}