سؤال

You know it is very easy to set transparent background of the control placed on the top of other control in WinForm by using the Parent method in C# like:

        LabelText.Parent = pictureBox1;

But it does not work in the Windows Mobile programming. I thought there in an other way to do so. enter image description here

I want to set the Label's background transparent, which is placed on the picturebox. In the above image the back colour of the label is already set to transparent but it displays the white colour instade of transparent.

هل كانت مفيدة؟

المحلول

You can get the kind of transparency you are looking for on the desktop version of .NET by overriding the Windows style flags for a control. You'd override CreateParams and turn on WS_EX_TRANSPARENT.

That's however not available on CF. The simple solution is to just override the Paint event of the PictureBox and draw the text with Graphics.DrawText(). With the added benefit that this is a lot cheaper than a Label control.

نصائح أخرى

The Winforms has no true transparency. There are some helpers for false transparency (like BackgroundImage, etc...) but it is not very powerfull.

Look at Alpha Mobile Controls project on CodePlex. It should solve your problem.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top