Is there any control or in way to use DateTime slider in windows form(是否有任何控件或方法可以在 Windows 窗体中使用 DateTime 滑块)
问题描述
我有一个 winForm,其中需要使用可以在 DateTime
上滑动的 Silder,并且网格会根据所选日期刷新.
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.
提前致谢.
推荐答案
是的,这个控件的名字是 TrackBar
.你可以不带标签地使用它:
Yes, this control has name TrackBar
. You can use it without labels:
DateTime beginDate = //
DateTime endDate = //
datesTrackBar.Maximum = (int)(endDate - beginDate).TotalDays;
并在 Scroll
事件上过滤您的网格:
And filter your grid on Scroll
event:
private void datesTrackBar_Scroll(object sender, EventArgs e)
{
DateTime selectedDate = beginDate.AddDays(datesTrackBar.Value);
// filter grid
}
或者您可以通过从 TrackBar
继承并覆盖它的 OnPaint
事件来创建自己的 TimeSlider
控件.
Or you can create your own TimeSlider
control via inheriting from TrackBar
and overriding it's OnPaint
event.
这里你可以看到一个创建自定义滑块的例子一个>.
这篇关于是否有任何控件或方法可以在 Windows 窗体中使用 DateTime 滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有任何控件或方法可以在 Windows 窗体中使用 DateTime 滑块


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01