如何使 Winforms 进度条在 C# 中垂直移动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/597411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make a winforms progress bar move vertically in C#?
提问by Krakerjak
I'm working on a WinForms Jukebox.
I'd like to have a vertical ProgressBar for the volume control.
我正在使用 WinForms Jukebox。
我想要一个用于音量控制的垂直 ProgressBar。
Does anyone know how to do that?
有谁知道这是怎么做到的吗?
采纳答案by Daniel LeCheminant
I don't know that I'd use a progress bar to controlthe volume, but to displaythe volume level you could use a user drawn control or you could just resize a label with a background color (that last method is kind of kludgy though)
我不知道我会使用进度条来控制音量,但是要显示音量级别,您可以使用用户绘制的控件,或者您可以只调整带有背景颜色的标签的大小(最后一种方法有点笨拙尽管)
The progress bar isn't meant to take input, no matter what the orientation.
无论方向如何,进度条都不是用来接受输入的。
If you really would like to controlthe volume, consider using a vertical scroll bar, or a trackbar with a vertical orientation.
如果您真的想控制音量,请考虑使用垂直滚动条或垂直方向的轨迹栏。
For what it's worth, there's a discussion on how to create a vertical progress bar on MSDN, where they suggest doing this:
对于它的价值,有关于如何在 MSDN 上创建垂直进度条的讨论,他们建议这样做:
using System;
using System.Windows.Forms;
public class VerticalProgressBar : ProgressBar {
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.Style |= 0x04;
return cp;
}
}
}
which sets the PBS_VERTICAL
flag in Style
.
将PBS_VERTICAL
标志设置为Style
.