【问题标题】:C# Form's background image as pictureBox parent?C# Form的背景图片作为pictureBox父级?
【发布时间】:2011-07-01 21:57:34
【问题描述】:

我有一个透明的图片框。我发现我可以使用 picturebox.Parent 来设置父图像,但它仅在 Parent 是另一个图片框时才有效。但是如果我想让表单的背景图片成为图片框的父级呢?

   pictureBox1.Parent = PictureBox2; //works fine (of course if there is a pbox2)
   pictureBox1.Parent = Form1;  //??? magic goes here

【问题讨论】:

    标签: c# picturebox windows-forms-designer


    【解决方案1】:

    如果我理解得很好,你希望你的背景是透明的。如果是这样,请使用:

    pictureBox1.BackColor = Color.Transparent;
    

    【讨论】:

    • 我试过了,但它给了我Error Cannot implicitly convert type 'System.Drawing.Color' to 'System.Windows.Forms.Control'
    • 啊,是的,没注意到BackColor。谢谢
    【解决方案2】:

    您是否尝试使用具有透明度的图像作为表单的背景?如果是这样,您不能这样做,您必须使用透明度键。

    你在上面尝试做的事情是这样的,但我不知道那会完成什么......

    Form1 theForm = new Form1();
    
    pictureBox1.Parent = theForm;
    

    【讨论】:

    • 不是。我正在尝试在具有背景图像的表单上使用透明图片框
    猜你喜欢
    • 1970-01-01
    • 2017-10-16
    • 2010-11-21
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    • 2011-07-28
    • 2020-09-09
    • 2017-12-30
    相关资源
    最近更新 更多