Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2008, 09:44 PM
Registered User
 
Join Date: Mar 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Background color of Controls on Winform

I want to create a Windows form with gradient background. So I use the code below to do this. And it works!

  Dim frmIn as Form
  Dim g As Graphics = frmIn.CreateGraphics
  Dim x As Integer = frmIn.Width
  Dim y As Integer = frmIn.Height
  Dim lgBrush As New LinearGradientBrush( _
        New Point(0, 0), New Point(x, y), _
        Color.White, Color.LightGreen)
  g.FillRectangle(lgBrush, 0, 0, x, y)

However, when I placed controls (like Label) onto the form, the background of the control do not match the background color and it becomes ugly. I tried to set the background color of the controls to "transparent" but seems like nothing change.

Please help!

Eins Tsang
 
Old March 26th, 2008, 08:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there, what do you see when you set the labels to transparent?? you should see the correct background.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old March 26th, 2008, 09:06 PM
Registered User
 
Join Date: Mar 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo,

I saw nothing different if I set the background to "transparent" or not, it still display the default color.

One thing to note is that: I am not using the background image of the form to do the decoration, I use the codes above in the Form_Paint event to "paint" the form. I know that using background image of form is workable.

Cheers,
Eins

Eins Tsang
 
Old March 26th, 2008, 09:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

MMM.. then you are getting the paint of the label before the paint of the form, there is your problem... what if you paint the rest of the controls before you paint the form (like setting them to visible only after the painting?)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
change color of background meena88 C# 2005 3 December 1st, 2009 04:48 AM
Background Color matrix ArnieStewart BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 3 October 21st, 2008 01:12 AM
mdi-background color avats General .NET 1 February 28th, 2008 10:25 AM
background-color disappears harpua CSS Cascading Style Sheets 1 August 19th, 2005 04:53 PM
Get stylesheet's background color muklee Javascript How-To 2 October 31st, 2004 08:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.