开发者

Set the background of the label transparant

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜