Hi all,
I've created a custom panel (inherited from Panel) that override OnPaint method to paint the inner rectangle with LinearGradientBrush.
public void PaintPanel()
{
// Re-calculate the
CalculatePanelHeight();
Graphics _g = this.CreateGraphics();
Point _startPoint = new Point(0, m_TopAreaHeight);
Size _size = new Size(Width, m_BtmAreaHeight);
Rectangle _btmRect = new Rectangle(_startPoint, _size);
LinearGradientBrush _btmGradBrush = new LinearGradientBrush(_btmRect, BackColorBottom, BackColorBottom2, LinearGradientMode.Vertical);
_btmGradBrush.GammaCorrection = true;
_g.FillRectangle(_btmGradBrush, _btmRect);
...
}
protected override void OnPaint(PaintEventArgs e)
{
PaintPanel();
base.OnPaint(e);
}
However there're 2 quirks: 1) Whenever any control with transparent background is dragged into the custom panel, its background becomes White.
2) my custom panel doesn't support transparent background (the color turns to White whenever I set one of the gradient color to transparent).
Would anyone offers some insights please?
Thank you.