问题
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