如何禁用 BindingNavigator 上的工具条项目?
我想以编程方式启用或禁用绑定导航器上的工具条项目。
当我尝试设置 toolStripitem 的启用属性时,它不会改变。 它不会给出任何异常,但 Enable 属性的值不会更改。
我错过了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BindingNavigator
本身控制这些按钮,以根据需要启用/禁用它们; 即,如果没有更多数据,则无法转到上一个/下一个,如果没有底层源允许,则无法添加/删除(IBindingList.AllowNew
/.AllowRemove
您想要调整哪些按钮?例如,您可以使用
BindingList
等数据源并设置AllowNew=false
来禁用添加/删除。 /AllowRemove=false
或者,只需完全编写自己的按钮(忘记
BindingNavigator
) - 这并不是很多工作,特别是如果您从开始。表单上的 BindingSource
(因为它具有所有必要的MoveFirst()
等。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 settingAllowNew=false
/AllowRemove=false
.Alternatively, simply write your own buttons completely (forget
BindingNavigator
) - it isn't a lot of work, especially if you start with aBindingSource
on the form (since that has all the necessaryMoveFirst()
etc.