datagridview datetimepicker C# 帮助
我有一个包含 10 列的 datagridview。每个月用户都会在网格中更新新信息。我想在绑定导航器旁边有一个日期时间选择器。日期时间选择器的用途是逐月向前或向后滚动。如果向前滚动,datagridview 将创建一个新的 datagridview,其中包含相同的 10 列,并填充了某些数据。然后用户只需添加新月份所需的数据即可。如果用户向后滚动一个月,datagridview 会显示用户过去已经更新过的网格视图和列。这是一种 datagridview 和月历之类的混合体。我到处寻找,但找不到任何关于如何添加此日期时间选择器控件的功能的想法。 任何想法都会非常有帮助。
I have a datagridview with 10 columns. Every month the user will update new info in the grid. I would like to have a datetimepicker next to the binding navigator. The purpose of the datetimepicker is to scroll forward or backward month by month. If scrolling forward the datagridview creates a new datagridview with the same 10 columns populated with certain data. Then the user can just add the necessary data for the new month. if the user scrolls backward a month, the datagridview shows past gridviews and columns the user has already updated in the past. This is sort of a hybrid of a datagridview and a monthly calendar sort of thing. I've looked everywhere and cannot find any ideas on how to add this datetimepicker control with functionality.
Any idea would be really helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 DateTimePicker 的 OnValueChanged 更新 BindingSource 上的筛选器。
DateTimePicker 有一个事件,表示它的值何时发生更改,您需要挂钩该事件。
该事件触发后,您需要获取 DateTimePicker 的值,并将绑定源上的过滤器设置为类似
"Date = '" + datePicker.toShortDateString() + "'"
这绑定源应该控制 datagridview 显示的内容。
Use the OnValueChanged for the DateTimePicker to update the Filter on the BindingSource.
The DateTimePicker has an event that signifies when it's value has changed, you want to hook into that.
Once that event has fired you want to take the value of the DateTimePicker, and set the filter on the binding source to something like,
"Date = '" + datePicker.toShortDateString() + "'"
This binding source should control what your datagridview displays.