Код: Выделить всё
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace CustomControls.GradientControls
{
public class Gradbtns : Button
{
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
pevent.Graphics.FillRectangle(new LinearGradientBrush(
new PointF(0, this.Height / 2), new PointF(this.Width, this.Height / 2),
Color.AliceBlue, Color.BurlyWood), this.ClientRectangle);
}
}
}
Но использование события OnPaintBackground активирует кнопку, но цвета не отображаются. См. изображение ниже
[img]https://i .sstatic.net/7ohMqase.png[/img]
Подробнее здесь: https://stackoverflow.com/questions/787 ... ndows-form
Мобильная версия