سؤال

I am working in C# 4.5 - Winform. My question is specific to C# WinForm.

I want to bind a Control's property to another control's property value on the same form.

I have a GroupBox and a Check Box. When Check box is checked then group box should be enabled and when CheckBox in un-checked then GroupBox should be disabled. However this task can be fulfilled by implement checkbox "CheckedChanged" event. But i want to accomplish this without writing any code. I dont know it is possible or not. If possible then please provide solution. enter image description here

هل كانت مفيدة؟

المحلول

It is possible to do via the designer. For your control -> Properties -> Binding...

But it is a lot of steps to result in a line of code in the designer file which you can add yourself just as easily in the constructor:

this.groupBox.DataBindings.Add( "Enabled", this.myCheckBox, "Checked" );
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top