Skip to content

The code generated by the DataGridView control has extra code for the RowTemplate.Height property #4461

Closed

Description

@Tanya-Solyanik
  • .NET Core Version:
    3.1+

  • Have you experienced this same bug with .NET Framework?:
    No

Problem description:

The generated code for dataGirdView1 has extra code for the RowTemplate.Height property. For the newly created control at 100% scaling, designer should generate the same value as is defined by the DefaultValueAttribute

image

Expected behavior:
RowTemplate.Height line should not be generated

image

Minimal repro:

  1. Create a Winforms .Net Core application.
  2. Add a DataGridView to from designer.
  3. Double click to open Form1.Designer.cs file in Solution Explorer.
  4. Observe the generated code of the dataGridView1.

Note from Dustin: DataGridViewRow.Height has a [DefaultValue(22)] attribute, so the code-gen above is expected if the value is 25.

Activity

  1. Tanya-Solyanik commented on Jan 13, 2021

    @Tanya-Solyanik
    ContributorAuthor

    DefaultValueAttribute should be adjusted to match the new default font

  2. added this to the 6.0 Preview1 milestone on Jan 14, 2021
  3. added
    tenet-compatibility
    area-VSDesigner
    on Jan 14, 2021
  4. modified the milestones: 6.0, 7.0 on Aug 27, 2021
  5. RussKie commented on Feb 21, 2022

    @RussKie
    Contributor

    Similar to #4463 (comment).

    Closing due to age. We can reopen it if/when we receive customer feedback.

  6. ghost removed this from the .NET 7.0 milestone on Feb 21, 2022
  7. kirsan31 commented on Feb 21, 2022

    @kirsan31
    Contributor

    @RussKie

    Closing due to age. We can reopen it if/when we receive customer feedback.

    You have it for a long time already.

    I was hoping that when you deal with this issue, I will be able to raise that too. Instead, you closed this one :)

    Current issue is more fatal then my previous. To break Font scaling in my reported issue you was needed to add some styles. But with this - when simple adding new DataGridView (not always - see below) to the form - you completely break DPI and Font scaling 😁 And even if you fix it manually, you have to do it again and again after every use of the designer...

    Details:

    1. this.dataGridView1.RowTemplate.Height = 25; line not always adding to Form1.Designer.cs. You need to open properties of dataGridView1 for this.
    2. There is a complete out of sync between the real values and what the designer shows.
    DGV1.mp4
    1. Broken DPI scale:

    Snipaste_2022-02-21_10-40-55

  8. 17 remaining items

  9. dkazennov commented on Jan 9, 2023

    @dkazennov
    Contributor

    Probably the best way to affect this Issue is to separate value of the Height property (in DataGridViewRow class) from the Thickness property (which in turn depends on Control.DefaultFont.Height). After that the DefaultValue attribute can be removed, new private const can be introduced as was proposed by @RussKie (with implementation of the Reset and ShouldSerialize methods).

    This sets the correct intended value to the property in the property browser, and there is still the extra code.

    image
    image

  10. ghost added
    🚧 work in progress
    on Jan 9, 2023
  11. kirsan31 commented on Jan 27, 2023

    @kirsan31
    Contributor

    @dkazennov thank you very match for doing this!

    I want ask the team about related (but designer) issue - any chance this will be fixed?
    It's really very tiring to delete extra font instances every time after changing the form in the designer, and if you forget about it, font scaling breaks :(

  12. paul1956 commented on Jan 27, 2023

    @paul1956
    Contributor

    I open 2 separate issue through Feedback with Extra Styles being generated for DataGridView and the format of the file alternates with every change (spaces are added and deleted) in comments and New Lines are deleted if initialized string is last before comment. Is the correct format for a comment the first or second, it seems to be inconsistent.

        '
        'Comment
       '
    

    or

         '
        ' Comment
        '
    

    Are there any test that compare results after each edit to look for side effects?

  13. Tanya-Solyanik commented on Feb 6, 2023

    @Tanya-Solyanik
    ContributorAuthor

    I want ask the team about related (but designer) issue

    The images are gone from the vs feedback website. @kirsan31 - could you please explain repro steps? Or even better - open individual issues in this repo.

    @merriemcgaw - FYI.

  14. kirsan31 commented on Feb 6, 2023

    @kirsan31
    Contributor

    The images are gone from the vs feedback website. @kirsan31 - could you please explain repro steps?

    Yea they are gone :( But we have gif form one of the responses:
    https://user-images.githubusercontent.com/4403806/118398742-578e5b00-b69d-11eb-9181-35f1045fb1f3.gif
    that explain one part of the issue.

    Or even better - open individual issues in this repo.

    Wil do...

  15. dmitrii-drobotov commented on Feb 7, 2023

    @dmitrii-drobotov
    Contributor

    We have those images in the linked designer issue (https://github.com/microsoft/winforms-designer/issues/2225), I will duplicate it here as well:
    [pic1.png]
    pic1
    [pic2.png]
    pic2
    [gif1.gif]
    gif1
    [gif2.gif]
    gif2

    @kirsan31 - can you confirm these are the same images from the feedback post?

  16. kirsan31 commented on Feb 7, 2023

    @kirsan31
    Contributor

    @dmitrii-drobotov

    @kirsan31 - can you confirm these are the same images from the feedback post?

    Yes, they are 👍
    Do I still need to create a new issue with them + description from original post?

  17. dkazennov commented on Feb 7, 2023

    @dkazennov
    Contributor

    @kirsan31 it would be great to have a new issue. Thanks!

  18. kirsan31 commented on Feb 8, 2023

    @kirsan31
    Contributor

    Or even better - open individual issues in this repo.

    Done: #8593

  19. ghost removed
    🚧 work in progress
    on Feb 24, 2023
  20. Nora-Zhou01 commented on Mar 3, 2023

    @Nora-Zhou01
    Contributor

    Verified this on .NET latest build: 8.0.100-preview.3.23152.5, issue was fixed, RowTemplate.Height line cannot be generated and DataGridViewRow.Height value is 25. The screenshot as same as above.
    data

    p

  21. ghost locked as resolved and limited conversation to collaborators on Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-VSDesignertenet-compatibility

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions