背景渐变

      关键词: 背景渐变、重写OnPaintBackground方法。

 

 

     GradientFill   class and the Win32Helper class可以在这找到

 

 

     The first thing I started with was to create a gradient background. I found that the best way achieving this would be to override OnPaintBackground in the Screen class. I found a very good article on how to do this on MSDN: How to display a gradient fill . I copied the GradientFill   class and the Win32Helper class into my project, I didn’t bother using the GradientFilledButton class since I only needed gradient for my background.

Then I override the OnPaintBackground in my Screen , giving me this Form :

  1. using System . Drawing ;
  2. using System . Windows . Forms ;
  3.  
  4. namespace GradientTransparentTest
  5. {
  6.     public partial class GradientTransparentForm : Form
  7.     {
  8.         public GradientTransparentForm ( )
  9.         {
  10.             InitializeComponent ( ) ;
  11.         }
  12.  
  13.         // Paints the background of the form with a GradientFill pattern.
  14.         protected override void OnPaintBackground ( PaintEventArgs e )
  15.         {
  16.             GradientFill. Fill (
  17.             e. Graphics , ClientRectangle,
  18.             Color. Silver , Color. LightBlue ,
  19.             GradientFill. FillDirection . LeftToRight ) ;
  20.             e. Graphics . Dispose ( ) ;
  21.         }
  22.     }
  23. }

This is what my simple Form with Gradient background looks like

gradient background

 

参考资料:


  http://www.cnblogs.com/chy710/archive/2009/09/15/1567210.html

http://breathingtech.com/2009/creating-gradient-background-with-transparent-labels-in-net-compact-framework/

 

转载于:https://www.cnblogs.com/xyzlmn/archive/2009/11/06/3168449.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值