我找到了解决办法。
在形式漆中添加:
this.BackColor = Color.Lime;
this.TransparencyKey = Color.Lime;
var hb = new HatchBrush(HatchStyle.Percent60, this.TransparencyKey);
e.Graphics.FillRectangle(hb, this.DisplayRectangle);
在形式负载使面板边缘轮,其中CTRL =面板。
Rectangle bounds = new Rectangle(0, 0, ctrl.Width, ctrl.Height);
int iCornerRadius = 20;
GraphicsPath gpath = new GraphicsPath();
gpath.AddArc(bounds.X, bounds.Y, iCornerRadius, iCornerRadius, 180, 90);
gpath.AddArc(bounds.X + bounds.Width - iCornerRadius, bounds.Y, iCornerRadius, iCornerRadius, 270, 90);
gpath.AddArc(bounds.X + bounds.Width - iCornerRadius, bounds.Y + bounds.Height - iCornerRadius, iCornerRadius, iCornerRadius, 0, 90);
gpath.AddArc(bounds.X, bounds.Y + bounds.Height - iCornerRadius, iCornerRadius, iCornerRadius, 90, 90);
gpath.CloseAllFigures();
ctrl.Region = new Region(gpath);
ctrl.Show();
现在很棘手。在winforms中创建圆角控件并不难,但将它们与半透明窗体结合起来很困难。 我可能已经解决了这个错误的方法,但是当我开始写这么多的代码时,我无法改变它。 正确的方法可能是从[Hans Passant](http://stackoverflow.com/users/17034/hans-passant)的[这个答案](http://stackoverflow.com/a/10267279/3094533)创建半透明背景,然后找出一种方法来阻止透明度键显示在角落附近。 –
我目前没有时间写出正确的答案,但也许别人可能会提供帮助。汉斯当你需要他的时候在哪里? –
等待您的回复.... – Rocky