开发者

Set the background of the label transparant

开发者 https://www.devze.com 2022-12-09 04:36 出处:网络
I have placed a picture as background to the form. protected override void OnPaintBac开发者_JAVA百科kground(PaintEventArgs e)

I have placed a picture as background to the form.

    protected override void OnPaintBac开发者_JAVA百科kground(PaintEventArgs e)
    {

        e.Graphics.DrawImage(bmp, 0, 0); 
    }

after that i placed a label over the form and set the backcolour to Transparent but it is not working. How can i get the transparency for the label backcolor


The previous answer doesn't work on the .NET CF due to using unsupported features of System.Windows.Forms. Within Windows Mobile it is not possible for a window (or control) to have a transparent background, so setting the background colour to transparent is ignored.

For the .NET CF the generally have to draw your own text on top of the parent control or window. Perhaps the example I like the best was originally proposed by Alex Yakhnin on this blog - http://blog.opennetcf.com/ayakhnin/PermaLink,guid,34221459-8db8-41ef-91c7-5514eade8fca.aspx

The theory is you place a standard label control on your form (so you can size and position it correctly etc) and then set it's Visible property to false. You then add code to the OnPaint event handler of the parent control or form to draw an equivalent piece of text relying upon the position, size and font information present in the hidden label control.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号