Skip to content

DataBindings: can't set formattingEnabled to false in designer #9552

Open

Description

@kirsan31

Environment

17.6.5

.NET version

All up to 7.0

Did this work in a previous version of Visual Studio and/or previous .NET release?

I think - no, 4.8 also checked.

Issue description

Designer always add bindings with formattingEnabled == true you can't change this behavior even if "Format type" == "No formatting":
image

Screen above will result in:

this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.paramsBindingSource, "checkState", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

More of it, if you manually change it to false in Form1.Designer.cs - any change in designer will revert it to true.
This is a critical bug for DataBindings. For example you can't bind to CheckState property of CheckBox with formattingEnabled == true - you will get error:
image
Maybe this is other bug? 🤔
So for now we need to do such a bindings manually outside of *.Designer.cs... 😭

Steps to reproduce

Build, run - try to click checkbox several times - you will see an error. If you change code in Form1.Designer.cs to:

this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.paramsBindingSource, "checkState", false, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

all will be ok.
DataBindingsFormatBug.zip

Activity

  1. added
    untriaged
    on Jul 24, 2023
  2. elachlan commented on Jul 24, 2023

    @elachlan
    Contributor
  3. added this to the VS release milestone on Jul 25, 2023
  4. KlausLoeffelmann commented on Jul 25, 2023

    @KlausLoeffelmann
    Member

    @Olina-Zhang and team:
    Could you re-test and confirm for latest Internal Preview and .NET Framework 4.8.1?
    Could you then create an issue in the Designer repo and assign me?

    Thanks!

  5. removed
    untriaged
    on Jul 25, 2023
  6. MelonWang1 commented on Jul 26, 2023

    @MelonWang1
    Contributor

    @KlausLoeffelmann Create a designer issue: 5387

  7. added
    area-VSDesigner
    on Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-VSDesigner

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions