Question

I want to enable or disable the toolstripitems on the bindingnavigator programmatically.

When I try to set the toolStripitem's enable property, it does not change. It does not give any exception but the value of Enable property does not change.

What did I miss?

Was it helpful?

Solution

The BindingNavigator takes control of these buttons itself, to enable/disable them as appropriate; i.e. you can't go prev/next if there is no more data, you can't add/delete without the underlying source letting you (IBindingList.AllowNew/.AllowRemove.

Which buttons do you want to tweak? For example, you can disable add/remove by using a data-source such as BindingList<T>, and setting AllowNew=false/AllowRemove=false.

Alternatively, simply write your own buttons completely (forget BindingNavigator) - it isn't a lot of work, especially if you start with a BindingSource on the form (since that has all the necessary MoveFirst() etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top