Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PictureBox Layout issue in c#

Tags:

c#

winforms

I am sure that my question or problem is really strange but this is it:

I am writing a program in c# which has a right to left layout (Arabic language). I am then adding the pictureBox control to be a background image in the form. I have set the dock of the pictureBox to be fill so it will be all the form.

Since the picture has some design that involves more than one color, I want to make the label transparent so that it does not have any color and it will take the color from the pictureBox itself. Here is how I make the label transparent:

label_customer_name.Parent = pictureBox1;

label_customer_name.BackColor = Color.Transparent;

This method works fine to change the color to transparent but there is a problem. When I set the parent of the label to be the pictureBox, the location of it changes and gets reflected on the other side. For example, if the location is set to be X after the execution, the location will be the form width - x. Any idea how to get rid of this problem?

What I am looking for in brief is:

  1. Is there any other way to make the label transparent without setting the parent to the container control? Or

  2. How to change the layout of PictureBox and force it to be from left to right.

Just as hint and the funny thing is that: if I add the pictureBox to a tab control and set the tab control to be right to left, the problem disappears as it seems that the pictureBox will get the layout from the tab control but it does not get it from the form itself.

like image 320
user2103335 Avatar asked Mar 06 '13 08:03

user2103335


1 Answers

Using GDI+ for Drawing Images with Transparency.

see this .

http://www.codeproject.com/Articles/25048/How-to-Use-Transparent-Images-and-Labels-in-Window

Good luck

like image 181
xwpedram Avatar answered Oct 11 '22 09:10

xwpedram