question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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; image

Expected behavior: The generated code for ListBox1 should not have this code: this.listBox1.ItemHeight = 15; image

Minimal repro:

  1. Create a Core winforms application.
  2. Add a ListBox control to form.
  3. Double click the Form1.Designer.cs file in Solution Explorer.
  4. 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:open
  • Created 3 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Tanya-Solyanikcommented, Mar 3, 2023

@dkazennov - FYI - ShouldSerialize and Reset methods should take into account DrawMode.OwnerDraw*

1reaction
MandiMancommented, Mar 2, 2023

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: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to .NET 4.5: An ItemsControl is inconsistent with ...
Exception message: This exception was thrown because the generator for control 'System.Windows.Controls.DataGrid Items.Count:5' with name '( ...
Read more >
ListBox Class (System.Windows.Forms)
The following code example demonstrates how to create a ListBox control that displays multiple items in columns and can have more than one...
Read more >
Control list box appearance and behavior - MATLAB
List boxes are UI components for displaying items in a list. Properties control the appearance and behavior of a list box. Use dot...
Read more >
ListBox Class | Wijmo API
The ListBox control displays a list of items which may contain plain text or HTML, and allows users to select items with the...
Read more >
Power Apps List Box Control - Complete tutorial
In this Power Apps tutorial, We will discuss what is a List box control in PowerApps, What are the List box control properties...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found