Question

I want to move the form title, icon and close, and help buttons from left side to right side (change the layout).

I moved the form controls manually to keep background image but now I want to change the form title.

When I set rightToLeft property to yes and rightToLeftLayout to true in the form properties the background image disappears, but it uses the property "BackColor"

My code is as follows:

if (_lang == 'Arabic')
{
    this.RightToLeft =  RightToLeft.Yes;
    this.RightToLeftLayout = true;
}

But it keeps buttons image.

So why is that?

Was it helpful?

Solution

To further Blounty's answer, the MSDN specs clearly state that BackgroundImage, Opacity and others aren't supported when using RightToLeftLayout:

http://msdn.microsoft.com/en-us/library/system.windows.forms.form.righttoleftlayout(vs.80).aspx:

Owner draw is not supported when RightToLeftLayout is set to Yes. The owner draw events will still occur, but the behavior of any code you author in these events is not defined. Additionally, BackgroundImage, Opacity, TransparencyKey, and the painting events are not supported.

OTHER TIPS

BackgroundImage, Opacity, TransparencyKey, and the painting events are not supported when RightToLeftLayout is set to yes.

It is pretty easy to replace the lost functionality:

protected override void OnPaintBackground(PaintEventArgs e) {
  Rectangle rc = new Rectangle(Point.Empty, this.ClientSize);
  e.Graphics.DrawImage(Properties.Resources.SampleImage, rc);
}

You'll need to do a bit more work if you need to tile the image.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top