如何在 C# 中使 winforms 进度条垂直移动?

发布于 2024-07-13 22:20:28 字数 79 浏览 2 评论 0原文

我正在开发 WinForms Jukebox。
我想要一个垂直的进度条来控制音量。

有谁知道这是怎么做到的吗?

I'm working on a WinForms Jukebox.
I'd like to have a vertical ProgressBar for the volume control.

Does anyone know how to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清醇 2024-07-20 22:20:28

我不知道我会使用进度条来控制音量,但要显示音量级别,您可以使用用户绘制的控件,或者只需调整大小带有背景颜色的标签(尽管最后一种方法有点笨拙)

进度条并不意味着接受输入,无论方向如何。

如果您确实想控制音量,请考虑使用垂直滚动条或带有垂直方向

对于它的价值,有 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; 
    } 
  } 
}

Style 中设置 PBS_VERTICAL 标志。

I don't know that I'd use a progress bar to control the volume, but to display the 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 control the 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:

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.

七堇年 2024-07-20 22:20:28

为此,您必须使用 ProgressBarRenderer。 它记录在 MSDN

文档实际上显示了实现垂直进度条,所以它应该让你很容易。 :-)

You have to use the ProgressBarRenderer for that. It's documented in MSDN

The documentation actually shows implementation of a vertical ProgressBar, so it should make it easy for you. :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文