Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public MaskedTextBoxTextEditorDropDown(MaskedTextBox maskedTextBox)
BackColor = Drawing.SystemColors.Control;
BorderStyle = BorderStyle.FixedSingle;
Name = "MaskedTextBoxTextEditorDropDown";
Padding = new Padding(16);
Size = new Drawing.Size(100, 52);
Padding = new Padding(LogicalToDeviceUnits(16));
Size = LogicalToDeviceUnits(new Drawing.Size(100, 52));
Comment thread
SimonZhao888 marked this conversation as resolved.
Outdated
((System.ComponentModel.ISupportInitialize)(_errorProvider)).EndInit();
ResumeLayout(false);
PerformLayout();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;

namespace System.Windows.Forms.Design.Tests;

public class MaskedTextBoxTextEditorDropDownTests
Expand Down Expand Up @@ -54,4 +56,20 @@ public void MaskInputRejected_SetsError_WhenInputRejected()
dropDownMaskedTextBox.Text = "invalid";
errorProvider.GetError(dropDownMaskedTextBox).Should().Contain(SR.MaskedTextBoxHintDigitExpected);
}

[Fact]
public void DropDown_SizeAndPadding_ScalesWithDPI()
{
using MaskedTextBox maskedTextBox = new();
using MaskedTextBoxTextEditorDropDown dropDown = new(maskedTextBox);

// The size and padding should be scaled based on DPI
// At 96 DPI (100%), Size should be (100, 52) and Padding should be (16, 16, 16, 16)
// At higher DPI, these values should scale proportionally
Size expectedSize = dropDown.LogicalToDeviceUnits(new Size(100, 52));
Padding expectedPadding = new(dropDown.LogicalToDeviceUnits(16));

dropDown.Size.Should().Be(expectedSize);
dropDown.Padding.Should().Be(expectedPadding);
}
Comment thread
SimonZhao888 marked this conversation as resolved.
}
Loading