locked
请教关于滚动条的问题 RRS feed

  • 问题

  • 在.NET中很多控件可以自绘,我也实现了大多数控件的美化,但唯独滚动条,尤其是在一些容器控件在内部控件超长时出现的滚动条,如何实现美化?
    非常感谢您关注我的问题.
    2009年8月23日 15:06

答案

  • Hi DYLIKE,

    很抱歉重写Panel似乎也没法重画它的ScrollBar。因为那个PaintEventArgs没有提供足够可以让你重绘的参数和控件的Handle。另外有个帖子也提到这个问题。

    原文如下:
    The scrollbars you see most often, including those built into most winforms controls, are rendered by Windows and there is no way to override their appearance in WinForms short of implementing an entirely custom solution which completely takes over the rendering and behavior of the common scrollbar control. There are some commercial packagages which claim to do this (google winforms skinning).

    http://stackoverflow.com/questions/126555/custom-painting-windows-forms-scrollbar

    大概意思就是控件里内置的那个ScrollBar是由Windows系统绘制的,通过重写控件不能重绘ScrollBar。然后他推荐使用第三方的皮肤控件来达到整体的美化效果。

    Sincerely,
    Kira Qian
    Please mark the replies as answers if they help and unmark if they don't.
    2009年8月25日 7:40

全部回复

  • 你好!
         请问是Paint事件中绘制无效吗?
    周雪峰
    2009年8月24日 1:04
    版主
  • 您好,我是指如Panel控件在AutoScroll=True时自动出现的滚动条ScrollBar,我如何才能自定义绘制它,如同其他控件的Paint()一样去绘制它.
    虽然不是专业,努力学.
    2009年8月24日 1:36
  • 可能只有重载panel,在Paint事件中绘制
    http://feiyun0112.cnblogs.com/
    2009年8月25日 1:23
    版主
  • 非常感谢回复,请问是否方便或者可以提供一份VB.NET重载滚动条的示例代码?


    虽然不是专业,努力学.
    2009年8月25日 2:07
  • 此外,我指的ScrollBar并非只存在于Panel,而是指任何带有ScrollBar的控件.
    虽然不是专业,努力学.
    2009年8月25日 2:08
  • Hi DYLIKE,

    很抱歉重写Panel似乎也没法重画它的ScrollBar。因为那个PaintEventArgs没有提供足够可以让你重绘的参数和控件的Handle。另外有个帖子也提到这个问题。

    原文如下:
    The scrollbars you see most often, including those built into most winforms controls, are rendered by Windows and there is no way to override their appearance in WinForms short of implementing an entirely custom solution which completely takes over the rendering and behavior of the common scrollbar control. There are some commercial packagages which claim to do this (google winforms skinning).

    http://stackoverflow.com/questions/126555/custom-painting-windows-forms-scrollbar

    大概意思就是控件里内置的那个ScrollBar是由Windows系统绘制的,通过重写控件不能重绘ScrollBar。然后他推荐使用第三方的皮肤控件来达到整体的美化效果。

    Sincerely,
    Kira Qian
    Please mark the replies as answers if they help and unmark if they don't.
    2009年8月25日 7:40
  • 非常感谢Kira Qian的回复,虽然无法在.NET中直接重绘它,但起码让我知道了"不是我一个人重绘不了",让我安心.再次感谢!
    虽然不是专业,努力学.
    2009年8月25日 8:19
  • 不客气。有问题请再来MSDN论坛。
    Please mark the replies as answers if they help and unmark if they don't.
    2009年8月25日 8:32