我正在开发一个Winforms应用程序,需要设置滚动条的设计。我需要更改箭头、滑块和曲目背景的颜色。我在msdn msdn ScrollBarRenderer Info上找到了一个ScrollBarRenderer,现在我不明白如何通过以下方法设置渲染
ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
ClientRectangle, ScrollBarState.Normal);
// Draw the thumb and thumb grip in the current state.
ScrollBarRenderer.DrawHorizontalThumb(e.Graphics,
thumbRectangle, thumbState);
ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics,
thumbRectangle, thumbState);
此代码在 OnPaint 中执行。
我将非常感谢任何帮助。
可悲的是,滚动条只是本机 Win32 API 的包装器,它不会公开栏的颜色。
其他控件允许你扩展自定义呈现器并使用它,但由于滚动条只是链接到 Win32 调用,因此无法在此处执行此操作。
实现此目的的唯一方法是创建从 Control 扩展的自定义绘制滚动条类,如代码项目上的此示例所示。
http://www.codeproject.com/Articles/41869/Custom-Drawn-Scrollbar