问题
In Windows Form When
RightToLeft=yes
and
RightToLeftLayout=true
i can not
set any background image for my form!
回答1:
From the MSDN entry for the Form.RightToLeftLayout property:
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.
回答2:
add a PictureBox and dock it to fill the form and you’ll get a background
回答3:
According to Prshanth's answer, you need to handle the background painting yourself.
Microsoft wasn't lazy, they simply didn't know what you want to be happening when the reading layout of the form is changed. Perhaps you want your background image to be flipped? They just don't know, so instead of doing something wrong, they did nothing.
The good thing is that you can simply do it yourself like this. In this example, I simply store the desired background image in a PictureBox and then paint it onto the form when the Form.Paint event occurs:
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
Dim r As Rectangle = Me.ClientRectangle
e.Graphics.DrawImage(Me.PictureBox1.BackgroundImage, r)
End Sub
来源:https://stackoverflow.com/questions/10764300/background-image-doesnt-show-when-right-to-left-is-true