Brush Constructor Question

J

Johnny J.

I've got an inherited control where I want the user to be able to specify a
color property. Using that color, I'm drawing a line

private m_UserDefinedColor as Color

.....

Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)

Then I want to draw a triangle filled with the same color. I set the point
and do:

g.FillPolygon(Brushes.Red, leftTriangle);

Because I can't figure out how to create a Brush that has the userdefined
color.

It's not possible to do: myBrush as Brush = new Brush(m_UserDefinedColor)

How do you specify the Brush Color in this case?

Cheers,

Johnny J.
 
R

rowe_newsgroups

I've got an inherited control where I want the user to be able to specify a
color property. Using that color, I'm drawing a line

private m_UserDefinedColor as Color

....

Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)

Then I want to draw a triangle filled with the same color. I set the point
and do:

g.FillPolygon(Brushes.Red, leftTriangle);

Because I can't figure out how to create a Brush that has the userdefined
color.

It's not possible to do: myBrush as Brush = new Brush(m_UserDefinedColor)

How do you specify the Brush Color in this case?

Cheers,

Johnny J.

IIRC you have to use one of the "other" brush objects (Solid,
Gradient, etc)

Something like:

Dim b As Brush = New SolidBrush(m_UserDefinedColor)

Thanks,

Seth Rowe
 

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