The code generated by the ListBox control is not consistent with Framework
See original GitHub issue-
.NET Core Version: 3.1+
-
Have you experienced this same bug with .NET Framework?: No
Problem description:
The generated code for ListBox1 have extra code: this.listBox1.ItemHeight = 15;
Expected behavior:
The generated code for ListBox1 should not have this code: this.listBox1.ItemHeight = 15;
Minimal repro:
- Create a Core winforms application.
- Add a ListBox control to form.
- Double click the Form1.Designer.cs file in Solution Explorer.
- Observe the generated code of the ListBox. Result: The generated code for ListBox1 should not have this code: this.listBox1.ItemHeight = 15;
Note from Dustin: ListBox.ItemHeight property.
dotnet/winforms@4bca5b3/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs#L596-L616
It has a [DefaultValue(DefaultItemHeight)]
attribute and DefaultItemHeight is 13.
Note from Tanya: Our default value is not accurate anymore due to the default font change. 13 is the default for Microsoft Sans Serif, 8.25pt, 15 is what comctl32 listbox calculates for Segoe UI, 9pt. To confirm - change the parent control’s font.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (10 by maintainers)
@dkazennov - FYI - ShouldSerialize and Reset methods should take into account DrawMode.OwnerDraw*
Verified on latest .NET 8.0 version 8.0.100-preview.3.23151.7 and the latest main build dll. Both results are the same and issue is still repro. Is it because of the 8640 PR influence? Please check below screenshot: