我有这个代码
ShadedRoundedRectangle rect = new ShadedRoundedRectangle();
rect.Location = new Point( 0, nextY );
rect.Size = new Size( 200, 20 );
rect.NewText = String.Format( "{0} x {1} ({2} kcals)", ci.Amount, ci.Product.ItemName, ci.Amount * ci.Product.Calories );
panel1.Controls.Add( rect );
ShadedRoundedRectangle
是一个用户控件,它绘制一个大小200,20
如您所见的阴影圆角矩形。添加rect
到面板控件集合时,大小更改为233, 23
.
用户控件已0,0,0,0
为padding
和margin
属性定义,我不知道为什么会发生这种情况。