transparent label...

M

Mustafa Rabie

hi all,

i know that transparent labels are not supported in netcf. So i added my
text in OnPaint, but actually the text is still not showing.. what am i
doing wrong? here's the OnPaint code:

protected override void OnPaint(PaintEventArgs e)

{

Graphics g = e.Graphics;

System.Drawing.Font f = new Font("Nina",
8,System.Drawing.FontStyle.Regular);

g.DrawString(this.label1.Text, this.label1.Font, new
System.Drawing.SolidBrush(System.Drawing.Color.Red), this.label1.Location.X,
this.label1.Location.Y );



base.OnPaint(e);

}

thanks

Mustafa
 
T

Tim Wilson

I assume that the OnPaint override is for a Form? Do you actually have a
Label named "label1" on the Form and if so does it have a Size? If so then
you might be drawing under your label. Also make sure that "label1.Text"
contains some text. Try drawing at 0,0 and see if that helps. Oh and don't
forget to Dispose of objects when you are done with them.
 
M

Mustafa Rabie

hi
i tried to put it @ 0,0 but still it's not showing anything, and yes i do
have a label1 that has text in it.
Did i mention that i have a picture box set as the form's background? the
setup is
Form, with a picture box (same size of the form) and i want to show the text
over it.

thanks
mustafa
 
P

Peter Foot [MVP]

In that case the text is behind the PictureBox. You'll need to draw that
image in your OnPaint too (before you draw the text). Any control you add to
the form is drawn on top of whatever is in your forms OnPaint.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top