none
Brushes? How do I pass a "Brushes" as a parameter?

    Question

  • Hi
    I want to fill a rectangle with a Colour.

    Graph.FillRectangle(Brushes.AliceBlue, x + 1, y + 1, W - 1, hgt - 1)

    That works fine  so whats my problem?
    Well i don't want to use the same colour all the time so i wrap it in a method and pass the color in as a parameter.
     But How?

    i tried something like

    Dim myBrushes As Brushes

    myBrushes = Brushes.Aquamarine    'to try and pass this as a parameter

    But i get "Value of Type System.drawing brush, cannot be converted to system drawing brushes"

    I don't get it .

    Could anyone explain this to me or point me to a description of brushes and how to use them that make sense?


    Thanks

    Mike Pooley

    Sunday, December 4, 2005 4:13 AM

Answers

  • Brushes is simply a class that contains commonly used brushes returned as shared (static in C#) properties. Each property in the Brushes class is of type Brush not Brushes. So you can simply do the following:


    Dim myBrushes As Brush

    myBrushes = Brushes.Aquamarine

     


    Brushes is not actually a createable type. For other types similar to Brushes see SystemBrushes, SystemColors, SystemFonts, Pens and SystemPens.
    Sunday, December 4, 2005 4:20 AM
    Moderator

All replies

  • Brushes is simply a class that contains commonly used brushes returned as shared (static in C#) properties. Each property in the Brushes class is of type Brush not Brushes. So you can simply do the following:


    Dim myBrushes As Brush

    myBrushes = Brushes.Aquamarine

     


    Brushes is not actually a createable type. For other types similar to Brushes see SystemBrushes, SystemColors, SystemFonts, Pens and SystemPens.
    Sunday, December 4, 2005 4:20 AM
    Moderator
  • Thank you!Idea

    so simple!  Tongue TiedTongue Tied
    Sunday, December 4, 2005 4:33 AM