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 滑块
基础教程推荐
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
