dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.36k stars 967 forks source link

LinkLabel image display abnormally #11680

Closed Liv-Goh closed 2 months ago

Liv-Goh commented 2 months ago

.NET version

.NET 9.0 SDK build: 9.0.100-preview.6.24328.19

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes, this is a regression issue. Not reproduce on .NET 8.0

Issue description

Current Behavior (.NET 9.0):

Expected Behavior (.NET 8.0):

Steps to reproduce

  1. Create a WinForms .NET 9.0 project
  2. Add a linkLabel component to the form
  3. Set the linkLabel font larger (e.g. 20) to observe the issue easier
  4. click ... in linkLabel Image property, import an image and click ok
  5. Add random component to the form (observe linkLabel behavior)
  6. Run the project (observe linkLabel behavior)

More Info linkLabel ImageList property have the similar behavior

lonitra commented 2 months ago

@LeafShi1 could you do an initial investigation to see what regressed here?

JeremyKuhne commented 2 months ago

Scratch project repro:

    private readonly LinkLabel _linkLabel1;

    public Form1()
    {
        InitializeComponent();

        Bitmap bitmap = new Bitmap(100, 100);
        using (Graphics g = Graphics.FromImage(bitmap))
        {
            g.Clear(Color.Red);
        }

        _linkLabel1 = new()
        {
            Font = new Font("Segoe UI", 48F, FontStyle.Regular, GraphicsUnit.Point, 0),
            Image = bitmap,
            Size = new Size(322, 86),
            Text = "linkLabel1"
        };

        Controls.Add(_linkLabel1);
        PerformLayout();
    }

Here is the regex I used to find the other mistaken using:

^\s*using\s[^\(].*;.$\s*{
Olina-Zhang commented 1 month ago

Verified this issue in the latest .NET 9.0 Preview 7 SDK build: 9.0.100-preview.7.24372.11, it was fixed: the image for LinkLabel display and refresh correctly in designer and runtime: image

MandiMan commented 1 month ago

Verified the issue with .NET 9.0.100-preview7.24407.12 test pass build that the issue has been fixed, which have the same results as above.