Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/System.Design/src/System.Design.Forwards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TreeNodeCollectionEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataMemberListEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataGridViewColumnDataPropertyNameEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataGridViewColumnCollectionEditor))]

// internal serializers
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ControlCodeDomSerializer))]
Expand Down
3 changes: 3 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,9 @@ Press Ctrl+Enter to accept Text.</value>
<data name="DataGridViewColumnTypePropertyDescription" xml:space="preserve">
<value>The DataGridViewColumn type.</value>
</data>
<data name="DataGridViewColumnCollectionTransaction" xml:space="preserve">
<value>DataGridView ColumnCollection Edit</value>
</data>
<data name="DesignBindingPickerAddProjDataSourceLabel" xml:space="preserve">
<value>Add new Object Data Source...</value>
</data>
Expand Down
5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf

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.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf

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,46 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;

namespace System.Windows.Forms.Design;
internal class DataGridViewColumnCollectionEditor : UITypeEditor
{
public DataGridViewColumnCollectionEditor() : base() { }

private DataGridViewColumnCollectionDialog? _dataGridViewColumnCollectionDialog;

public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value)
{
IWindowsFormsEditorService? edSvc = provider?.GetService<IWindowsFormsEditorService>();

if (provider is null || edSvc is null || context?.Instance is null
|| provider.GetService(typeof(IDesignerHost)) is not IDesignerHost host)
{
return value;
}

using (ScaleHelper.EnterDpiAwarenessScope(DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE))
{
_dataGridViewColumnCollectionDialog ??= new();

_dataGridViewColumnCollectionDialog.SetLiveDataGridView((DataGridView)context.Instance);

using DesignerTransaction trans = host.CreateTransaction(SR.DataGridViewColumnCollectionTransaction);
if (edSvc.ShowDialog(_dataGridViewColumnCollectionDialog) == DialogResult.OK)
{
trans.Commit();
}
else
{
trans.Cancel();
}
}

return value;
}

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.Modal;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using Moq;
using System.ComponentModel;
using System.Drawing.Design;

namespace System.Windows.Forms.Design.Tests;

public class DataGridViewColumnCollectionEditorTests
{
[Fact]
public void DataGridViewColumnCollectionEditor_GetEditStyle()
=> new DataGridViewColumnCollectionEditor().GetEditStyle().Should().Be(UITypeEditorEditStyle.Modal);

[Fact]
public void DataGridViewColumnCollectionEditor_IsDropDownResizable()
=> new DataGridViewColumnCollectionEditor().IsDropDownResizable.Should().Be(false);

[Fact]
public void DataGridViewColumnCollectionEditor_EditValue()
{
DataGridViewColumnCollectionEditor dataGridViewColumnCollectionEditor = new();
object value = "123";
dataGridViewColumnCollectionEditor.EditValue(null, null!, value).Should().Be(value);

Mock<ITypeDescriptorContext> mockTypeDescriptorContext = new(MockBehavior.Strict);
dataGridViewColumnCollectionEditor.EditValue(mockTypeDescriptorContext.Object, null!, value).Should().Be(value);

Mock<IServiceProvider> mockServiceProvider = new(MockBehavior.Strict);
mockServiceProvider.Setup(x => x.GetService(typeof(IWindowsFormsEditorService))).Returns(null!);
dataGridViewColumnCollectionEditor.EditValue(null, mockServiceProvider.Object, value).Should().Be(value);

mockTypeDescriptorContext.Setup(x => x.Instance).Returns(null!);
dataGridViewColumnCollectionEditor.EditValue(null, mockServiceProvider.Object, value).Should().Be(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DesignerAttributeTests
$"System.Windows.Forms.Design.DataGridTableStyleMappingNameEditor, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.DataGridDesigner, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.DataGridViewColumnDataPropertyNameEditor, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.DataGridViewComponentEditor, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.DataMemberFieldEditor, {Assemblies.SystemDesign}",
$"System.Windows.Forms.Design.StatusBarDesigner, {Assemblies.SystemDesign}",
Expand Down
Loading