【问题标题】:Change background of the thumb of Trackbar更改 Trackbar 拇指的背景
【发布时间】:2013-04-29 03:06:13
【问题描述】:

有什么方法可以改变 Trackbar 的拇指背景吗?我使用 C# winform。
只能更改Trackbar的背景,如何更改或设置拇指中的内容?

任何答案表示赞赏。

【问题讨论】:

    标签: c# winforms trackbar


    【解决方案1】:

    我看到了这个项目:

    http://www.codeproject.com/Articles/7974/A-variation-on-the-default-TrackBar

    并添加它的图片让用户选择:

        /// <summary>
        /// Set Image of Trackbar's thumb
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        [Description("Set the picture of the thumb")]
        [Category("Image")]
        public Image Picture
        {
            set
            {
                myPic = value;
            }
            get { return myPic; }
        }
    

    并使用 TextureBrush 让人们选择的图片是 ImageBrush:

     TextureBrush newBrush = new TextureBrush(myPic);
     if (myPic != null)
     {
          g.FillRegion(newBrush, new Region(PaintPath));
          newBrush.Dispose();
     }
     else
     {
          g.FillRegion(bgBrush, new Region(PaintPath));
          bgBrush.Dispose();
     }
    

    只有一个问题,画笔是平铺样式,

    如果我让它不是平铺样式,它可能会解决我的问题。

    【讨论】:

      猜你喜欢
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-03
      • 1970-01-01
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多