By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

VS 2005 (VB) Linear Gradient Bug?

P: n/a
I am using Visual Studio 2005 with Visual Basic.

I am trying to create a vertical color-gradient rectangle. I want the
rectangle to go from red on top to blue on the bottom.

This is the routine I am using:

RectHeight = 50

Dim RCT As New Rectangle(10, 10, 40, RectHeight)

Dim LGB As New LinearGradientBrush(RCT, Color.Red, Color.Blue,

Dim NewReg = New Region(RCT)

gr.FillRegion(LGB, NewReg)
If I use the above value (RectHeight = 50) for the height of the
rectangle it looks correct. If I instead use:

RectHeight = 51

Then the rectangle gets goofed. The very top line will have the
"bottom" color but the rest of the rectangle looks correct. If the
height of the rectangle is evenly divisible by 2, then it will look
correct. If the height is an odd value then the rectangle will display
the wrong color at the top line every time.

Anyone else experience this? Something stupid I am doing in the code?

Feb 12 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.