Formularios en C#

Para mejorar la apariencia de nuestros formularios o  paneles podemos agregar un color gradiente.
El color gradiente es esta forma

Para realizar eso en c#.Debemos tocar el metodo paint del objeto en cuestion y agregar el namespace
using System.Drawing.Drawing2D;
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    /* Get Graphics Object Who painted the Form */
    Graphics g = e.Graphics;

    /* Define Rectangle Area in Which We Want to Work Usually Forms Whole area */
    Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

    /* Take a Linear Gradient Brush */
    LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Orange, Color.Orchid, LinearGradientMode.ForwardDiagonal);

    /* Fill That Rectangle Area With Brush Paint */
    g.FillRectangle(brush, rect);
}

Comentarios