如何在 .net 3.5 轨迹栏中标记最小、最大、中心刻度?
我需要在应用程序中设置电压。我习惯在 Labview 中使用滑块,并且想使用 C# 程序来复制它。
我发现轨迹栏只处理整数值,因此我需要让轨迹栏从 -50 到 +50,每 10 步使用刻度线,而不是使用双精度值将范围从 -5 到 5获得 0.1v 分辨率。
如何标记轨迹栏的最小值和最大值?
|-----|-----|-----|-----|-----|-----|-----|-----|- ----|-----|
-5.0 0.0 5.0
我正在使用 C# 和 .net 3.5 以及 Visual Studio。
I need to set a voltage in an application. I'm used to using sliders in Labview, and would like to replicate that using a C# program.
I've figured out that the track bar only does integer values, so rather than have the range go from -5 to 5 using a double, I need to have the track bar go from -50 to +50 with tick marks every 10 steps to get 0.1v resolution.
How do I label the track bar minimum and maximum values?
|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
-5.0 0.0 5.0
I'm using C# with .net 3.5 with Visual Studio.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是添加 2-3 个标签,使用轨迹栏的高度/宽度/顶部/左侧的组合,您应该能够相对定位它们,而不需要太多麻烦?
编辑:另外,似乎这个post 显示了与您描述的要求相同的自定义实现?
The easiest way would be to add to 2-3 labels, using a combination of height/width/top/left of the trackbar and labels you should be able to position them relatively without too much hassle?
EDIT: Also, it seems this post shows a custom implementation with the same requirements as you've described?
TrackBar 比例图像链接
我所做的是修改图表并使用其 X 轴比例作为TrackBar(请参阅图像链接[我会嵌入图像,但无法使其工作])。图像的上半部分是滑块,下半部分是常规图表对象,其属性已更改,因此唯一可见的是其 X 轴。
下面是 TrackBar 和 Chart 的 VS2010 表单设计器代码。此示例将为您提供 0 到 100 的比例,您可以轻松调整其大小以与轨迹栏对齐。您甚至可以将这两个控件放在一个面板中,以便可以轻松地调整它们的大小(代码是 VB 而不是 C#):
TrackBar Scale Image Link
What I've done is modify a chart and used its X axis scale as the scale for the TrackBar (See link for image [I would have embedded image but I couldn't get it to work]). The top half of the image is the slider and the bottom half is a regular chart object with it properties changed so the only thing visible is its X axis.
Here's the VS2010 Form Designer code for the TrackBar and Chart. This example will give you a scale of 0 to 100 which can easily be resized to line up with your trackbar. You could even put both controls in a panel so they can be easily resized as one (Code is VB rather than C#):