Is there any control or in way to use DateTime slider in windows form

久未见 提交于 2019-12-11 04:59:00

问题


I have a winForm, in which have a requirement to use Silder that could slide on DateTime and grid is refreshed according to the date selected.

Is there any control that provides above functionality.

Thanks in advance.


回答1:


Yes, this control has name TrackBar. You can use it without labels:

DateTime beginDate = //
DateTime endDate = //
datesTrackBar.Maximum = (int)(endDate - beginDate).TotalDays;

And filter your grid on Scroll event:

private void datesTrackBar_Scroll(object sender, EventArgs e)
{
    DateTime selectedDate = beginDate.AddDays(datesTrackBar.Value);
    // filter grid
}

Or you can create your own TimeSlider control via inheriting from TrackBar and overriding it's OnPaint event.

Here you can see an example of creating custom slider.



来源:https://stackoverflow.com/questions/13112869/is-there-any-control-or-in-way-to-use-datetime-slider-in-windows-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!