I want to enable or disable the toolstripitems on the bindingnavigator programmatically.
我想以编程方式启用或禁用bindingnavigator上的toolstripitems。
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.
当我尝试设置toolStripitem的enable属性时,它不会改变。它不会给出任何异常,但Enable属性的值不会更改。
What did I miss?
我错过了什么?
1 个解决方案
#1
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
.
BindingNavigator控制这些按钮本身,以适当地启用/禁用它们;即如果没有更多数据,你不能进入上一个/下一个,你不能添加/删除没有底层来源让你(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
.
你想调整哪些按钮?例如,您可以使用BindingList
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.
或者,只需完全编写自己的按钮(忘记BindingNavigator) - 这不是很多工作,特别是如果你从表单上的BindingSource开始(因为它具有所有必要的MoveFirst()等。
#1
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
.
BindingNavigator控制这些按钮本身,以适当地启用/禁用它们;即如果没有更多数据,你不能进入上一个/下一个,你不能添加/删除没有底层来源让你(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
.
你想调整哪些按钮?例如,您可以使用BindingList
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.
或者,只需完全编写自己的按钮(忘记BindingNavigator) - 这不是很多工作,特别是如果你从表单上的BindingSource开始(因为它具有所有必要的MoveFirst()等。