Problem painting WinForm with Linear Gradient background


David Clegg

I'm trying to create a form with a Linear Gradient background. Thats
easy enough, but any Labels I have on the form do not have their
background painted correctly. Even though I have Label.BackColor set to
Color.Transparent, it is using the original BackColor of the Form. Here
is my code, which is called in the Paint event for the Form ...

private void LoginForm_Paint(object sender,
System.Windows.Forms.PaintEventArgs e) {

LinearGradientBrush brush = new LinearGradientBrush(
e.ClipRectangle, Color.Black, Color.Blue,
e.Graphics.FillRectangle(brush, this.ClientRectangle);

Am I going to have to override the Paint event for the Label components
as well and manually output the text?

David Clegg

"I know I'm not usually a praying man, but if you're up there, please
Superman, help me!" - Homer Simpson

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