Sunday, 30 December 2012 16:35

showing gradient colored background in application form

Written by 
Rate this item
(0 votes)

It's nice to show cool gradient color as a
background color of the form in desktop can set different colors.

1.first add the frmMain_Paint method in the
Paint event of the form from the form properties

2.then add the method in your form -

private void frmMain_Paint(object sender, PaintEventArgs e)
Graphics g = e.Graphics;
Rectangle bounds = new Rectangle(Point.Empty, this.Size);
if (bounds.Width > 0 && bounds.Height > 0)
using (Brush b = new LinearGradientBrush(bounds,
Color.White, Color.Green,LinearGradientMode.Horizontal))
g.FillRectangle(b, bounds);
}}} your application,you will see nice gradient
color.change color from White and Green to your
favourite colors and run app again.

Read 2738 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.