Guarda la classe è definita partial perchè siamo più persone a lavorarci sopra.
Qui sotto ti scrivo per bene il codice: dimmi cosa ne pensi!
namespace NCManager.ControlsLib
{
public partial class ComboBoxCtrl : ComboBox
{
private void InitializeCtrl()
{
}
public ComboBoxCtrl()
{
InitializeCtrl();
}
protected override void OnPaint(PaintEventArgs e)
{
Rectangle BaseRectangle = new Rectangle(0, 0, this.Width - 1 , this.Height - 1);
Brush Gradient_Brush =
new LinearGradientBrush(
BaseRectangle,
BackColor, Color.WhiteSmoke,
LinearGradientMode.Vertical);
e.Graphics.FillRectangle(Gradient_Brush, BaseRectangle);
Pen forePen = new Pen(ControlPaint.LightLight(Color.Gray), SystemInformation.BorderSize.Height);
Pen forePenDark = new Pen(ControlPaint.Dark(Color.Black), SystemInformation.BorderSize.Height);
Point lineLeft = new Point(ClientRectangle.Left + SystemInformation.BorderSize.Width, ClientRectangle.Top);
Point lineRight = new Point(ClientRectangle.Right, ClientRectangle.Top);
Point lineTopLeft = new Point(ClientRectangle.Left, lineLeft.Y);
lineTopLeft.Offset(SystemInformation.BorderSize.He ight, SystemInformation.BorderSize.Height);
Point lineTopRight = new Point(ClientRectangle.Right, lineRight.Y);
lineTopRight.Offset(-SystemInformation.BorderSize.Height, SystemInformation.BorderSize.Height);
Point lineBottomLeft = new Point(ClientRectangle.Left, ClientRectangle.Bottom);
lineBottomLeft.Offset(SystemInformation.BorderSize .Height, -SystemInformation.BorderSize.Height);
Point lineBottomRight = new Point(ClientRectangle.Right, ClientRectangle.Bottom);
lineBottomRight.Offset(-SystemInformation.BorderSize.Height, -SystemInformation.BorderSize.Height);
if (FlatStyle == FlatStyle.Flat)
{
e.Graphics.DrawLine(forePenDark, lineLeft, lineRight);
e.Graphics.DrawLine(forePenDark, lineBottomLeft, lineBottomRight);
e.Graphics.DrawLine(forePenDark, lineTopLeft, lineBottomLeft);
e.Graphics.DrawLine(forePenDark, lineTopRight, lineBottomRight);
}
else
{
base.OnPaint(e);
}
forePenDark.Dispose();
forePen.Dispose();
}