在绑定源当前项更改事件上重新分配 textbox.text
我正在学习绑定源等。我已经添加了我的文本框数据绑定,如下所示:
txtTitle.DataBindings.Add("Text", bindingNavigator1.BindingSource.Current, "Title");
当用户单击导航器上的下一个按钮时,我是否必须处理绑定源当前项目更改事件来表示
txtTitle.Text = ((MyObject)bindingsource.CurrentItem).Title??
我认为这将是自动的,因为我有一个很多控件看起来很乏味
I am just learning bindingsources etc. I have added my textbox databindings like so:
txtTitle.DataBindings.Add("Text", bindingNavigator1.BindingSource.Current, "Title");
When the user clicks the next button on the navigator do I have to handle the bindingsource currentitem changed event to say
txtTitle.Text = ((MyObject)bindingsource.CurrentItem).Title??
I would have thought this would be automatic as I have a lot of controls so seems tedious
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该绑定到绑定源本身,如下所示:
然后您不需要处理任何进一步的事件。正如你所说,那会很乏味。
You should bind to the bindingsource itself as in:
Then you don't need to handle any further events. As you say, that would be tedious.