Background Image Doesnt Show When Right To Left Is True

强颜欢笑 提交于 2019-12-08 05:00:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!