在另一个PictureBox顶部的C#PictureBox [英] C# PictureBox on top of another PictureBox

查看:174
本文介绍了在另一个PictureBox顶部的C#PictureBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望pbGrade位于pbItemtype的顶部(pb =图片框)

I want the pbGrade to be on top of pbItemtype (pb = picture box)

 pbItemtype.BackColor = Color.Transparent;

 // Change parent for overlay PictureBox...
 pbItemtype.Parent = pbGrade;

我已经尝试过了,但是pbItemtype甚至没有出现,而且两个图片框都更改了图像(pbItemtype和pbGrade)

I already tried this but then the pbItemtype is not even appearing, also the 2 picture boxes change images (pbItemtype and pbGrade)

推荐答案

实际上,您可以轻松地做到这一点,而事实上您已经做到了.

Well actually you can do that easily and in fact you already did.

代码有效,但是您还需要更正Location,因为嵌套的PB会将其保留为先前的PB,因此可能会移到右下角,可能会留下可见的大小.新的Parent ....:

The code works but you also need to correct the Location as the nested PB will keep it previous one and thus will probably be off to the bottom right, probably leaving the visible size of the new Parent.... :

pbItemtype.BackColor = Color.Transparent;

// Change parent for overlay PictureBox...
pbItemtype.Parent = pbGrade;
// Move it to the top left of the parent:
pbItemtype.Location = Point.Empty;  // or some other position..

嵌套控件时,

透明效果很好.但是,当重叠它们时,它不起作用!

Transparency works well when nesting controls. It doesn't work when overlapping them, though !

(当然,我们看到的代码将交换图像!)

(Of course the code we see will not exchange the images!)

这篇关于在另一个PictureBox顶部的C#PictureBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆