Drawing2D Code not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

this code should work:
Using gb As New LinearGradientBrush(e.CellBounds,
Colors.OfficeColor1, Colors.OfficeColor2, LinearGradientMode.Vertical)
Dim b As Blend = New Blend(5)
b.Factors = New Single() {0.2F, 0.4F, 0.6F, 0.8F, 1.0F}
b.Positions = New Single() {0.1F, 0.2F, 0.3F, 0.4F, 0.5F}
gb.Blend = b
e.Graphics.FillRectangle(gb, e.CellBounds)
End Using

the line: gb.Blend = b throws an ArgumentException: Parameter is not Valid..
anyone know why? this code is almost verbatim from a MS example in VS 2005
help
 
If you read the Help for the Blend.Positions property a little more closely,
you'll find this remark:

The elements of this array specify percentages of distance along the
gradient line. For example, an element value of 0.2f specifies that this
point is 20 percent of the total distance from the starting point. The
elements in this array are represented by float values between 0.0f and 1.0f.
The first element of the array must be 0.0f, and the last element must be
1.0f.

Tony
 
Back
Top