Why is Databinding for a CheckedListBox “Hidden”?

2019-06-26 15:22发布

问题:

The DataSource property on a CheckedListBox is hidden from Intellisense. Why? You can use the binding properties to make it work, but I'm worried that it's hidden for a reason and that I shouldn't be databinding on a CheckedListBox for some important reason that I'm not aware of.

Is databinding on a CheckedListBox ok??

回答1:

The CheckedListBox is intended to be used with its Add and AddRange methods:

To add objects to the list at run time, assign an array of object references with the AddRange method. The list then displays the default string value for each object. You can add individual items to the list with the Add method.

While data binding to the CheckedListBox may work you ought to avoid creating dependencies on anything but the public interface of a type. I would recommend that you use the proper methods as this will make you code less brittle in the event that Microsoft changes the implementation of CheckedListBox.