Skip to content

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

@kirsan31

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

Metadata

Metadata

Labels

area-VSDesignerWindows Forms out-of-proc designer related issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions