我得到以下错误:
错误4"System.Windows.Forms.ToolStripButton"不包含"Transparent"的定义,并且找不到接受类型为"System.Windows.Forms.ToolStripButton"的第一个参数的扩展方法"Transparente"(是否缺少using指令或程序集引用?)C:\Users\E1\Desktop\text editor\editor\Form1.cs 321 34 editor
我正在尝试实现以下代码:
protected void PaintTransparentBackground(Graphics graphics, Rectangle clipRect)
{
graphics.Clear(Color.Transparent);
if ((this.Parent != null))
{
clipRect.Offset(this.Location);
PaintEventArgs e = new PaintEventArgs(graphics, clipRect);
GraphicsState state = graphics.Save();
graphics.SmoothingMode = SmoothingMode.HighSpeed;
try
{
graphics.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
this.InvokePaintBackground(this.Parent, e);
this.InvokePaint(this.Parent, e);
}
finally
{
graphics.Restore(state);
clipRect.Offset(-this.Location.X, -this.Location.Y);
}
}
}
它说toolstrip按钮不包含该定义。我想为标签页做这件事,但似乎不起作用。从未经历过这样的问题。
有什么提示吗?
试着在Color.Transparent前面添加System.Drawing。我猜你的表单类中有一个定义为Color的属性。
graphics.Clear(System.Drawing.Color.Transparent);
如果这样做成功了,那么我建议您将Color属性重命名为更具体的属性,比如ColorButton或其他什么。