Results 1 to 6 of 6

Thread: [RESOLVED] Background color

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2011
    Location
    Dorset, UK
    Posts
    72

    Resolved [RESOLVED] Background color

    I have an array holding certain color values (ie whitesmoke, samon etc) which is obtained from an external text file. A bit like a style sheet. anyway, these values are loaded into an array and used to change the style of the application. The only issue is im getting a few errors.

    Code:
     Me.BackColor = Color.StyleConfig(0)
    Does not work.
    I am drunk, you are ugly. But in the morning I will be sober.
    Sir Winston Churchill

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Background color

    So you're getting a few errors. If only there was a way for us to know what those errors are.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2011
    Location
    Dorset, UK
    Posts
    72

    Re: Background color

    sorry, it says

    'styleConfig' is not a member of system.drawing.color
    I am drunk, you are ugly. But in the morning I will be sober.
    Sir Winston Churchill

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2011
    Location
    Dorset, UK
    Posts
    72

    Re: Background color

    sorted it.

    Code:
    Me.BackColor = Color.FromName(StyleConfig(0))
    I am drunk, you are ugly. But in the morning I will be sober.
    Sir Winston Churchill

  5. #5
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: [RESOLVED] Background color

    Nice. It wouldn't hurt to check that the colour it returns is a valid colour before using it, though. Look to the Color.IsKnownColor Property, which returns a Boolean.

    Code:
    Dim bckColour As Color = Color.FromName(styleConfig(0))
    
    If bckColour.IsKnownColor Then
        Me.BackColor = bckColour
    Else
        MessageBox.Show("Unknown colour: " & styleConfig(0))
    End If

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2011
    Location
    Dorset, UK
    Posts
    72

    Re: [RESOLVED] Background color

    Quote Originally Posted by Inferrd View Post
    Nice. It wouldn't hurt to check that the colour it returns is a valid colour before using it, though. Look to the Color.IsKnownColor Property, which returns a Boolean.

    Code:
    Dim bckColour As Color = Color.FromName(styleConfig(0))
    
    If bckColour.IsKnownColor Then
        Me.BackColor = bckColour
    Else
        MessageBox.Show("Unknown colour: " & styleConfig(0))
    End If
    Good point. Thanks for that.
    I am drunk, you are ugly. But in the morning I will be sober.
    Sir Winston Churchill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width