Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checkbox databinding

I have a problem with System.Window.Form.CheckBox databinding. I have code:

checkBox1.DataBindings.Add("Checked", _movementsBindingSource, "Moved", true);

It's working, but i want invert checkBox1.Checked. If Moved is true, then checked = false. Can you help me with this problem?

like image 699
Alex Avatar asked May 19 '11 10:05

Alex


1 Answers

That's a common problem and you have two options:

  1. Create another field in the _movementsBindingSource which will be exact inverse of the 'Moved' field and bind to it.
  2. Do the databinding manually and handle the checked changed events yourself.

By default, databinding doe not have an 'inverse bool binding' sort of an option.

like image 169
Teoman Soygul Avatar answered Sep 21 '22 11:09

Teoman Soygul