DyLike的指点:
窗体上放两个LABEL
Private Function DisableImage(img As Image) As Image
Dim b As New Bitmap(img.Width, img.Height)
Using g As Graphics = Graphics.FromImage(b)
ControlPaint.DrawImageDisabled(g, img, 0, 0, Control.DefaultBackColor)
End Using
Return b
End Function
调用方法:
Me.PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
Me.PictureBox2.Image = DisableImage(Image.FromFile("F:\Icon\Arrows\arrowB128.png").Clone)
后来在网上也找到了下面的文章。
C# 画自定义控件Enabled为false时候的灰色图片
2009-07-17 11:34
做了个自定义按钮控件,但Enabled为false的时候背景颜色和图标的颜色都要自己再去画,背景颜色倒很好搞定,图标就有点麻烦了,不过还是在网上找到了,也就一句代码:
System.Windows.Forms.ControlPaint.DrawImageDisabled(g, this.Image, ImagePoint.X,ImagePoint.Y, this.BackColor); 来源: http://heisetoufa.javaeye.com/blog/347426 |
--