Jump to content

System.Drawing.Color, System.Drawing.Pens and System.Drawing.Brushes

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
In VB.NET there's 3 types of color data types(System.Drawing.Color, System.Drawing.Pens and System.Drawing.Brushes) depending on what you'll use it for. Is there anyway for me to convert a color between this three. For example if I have a give color as the color datatype, is it then possible for me to create a brush and a pen from it?


This problem has bothered me for a long time so I would be glad to get some help

Thanks /Vswe :)

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Since no one have answered this I will now answer this for anyone else having the same trouble.

        Dim myColor As Color
        Dim myBrush As Brush
        Dim myPen As Pen

        'From Color to brush/pen
        myBrush = New SolidBrush(myColor)
        myPen = New Pen(myColor)

        'From Brush to color/pen
        myPen = New Pen(myBrush)
        myColor = New Pen(myBrush).Color

        'From Pen to color/brush
        myColor = myPen.Color
        myBrush = New SolidBrush(myPen.Color)