我正在尝试绘制具有渐变背景效果的面板。我面板内有3个按钮。按钮也画了。如何在没有子控件的情况下仅绘制面板
void pnl_Paint(object sender, PaintEventArgs e)
{
//Create a diagonal linear gradient with four stops.
LinearGradientBrush myLinearGradientBrush =
new LinearGradientBrush(e.ClipRectangle,
Color.Red, Color.White,
LinearGradientMode.Horizontal);
ColorBlend cb = new ColorBlend();
Color c1 = StringToColor("FFAD5C");
Color c2 = StringToColor("ffffff");
Color c3 = StringToColor("FFAD5C");
cb.Positions = new[] { 0, (float)0.75, 1 };
cb.Colors = new[] { c1, c2, c3 };
myLinearGradientBrush.InterpolationColors = cb;
e.Graphics.FillRectangle(myLinearGradientBrush, e.ClipRectangle);
}