Results 1 to 5 of 5

Thread: Writing Colors to a file?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    4

    Writing Colors to a file?

    Don't know if I should use save Settings And get settings to save the color of a label everytime the program closes, then gets it when it opens?

    I have this but I am just confused on how to get it to read the color of the label

    Code:
    #
    SaveSetting(Application.ProductName, Application.ProductName, "label1", label1.text)
    Code:
       label1.text = GetSetting(Application.ProductName, Application.ProductName, "label1")
    Don't Understand how that would read the color. Thanks in advanced

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,187

    Re: Writing Colors to a file?

    Don't use SaveSetting and GetSetting for anything.

    Open the project properties to the Settings page and add settings of type Color there. You can then access them via My.Settings in code. The data is loaded at startup and saved at shutdown automatically. You can even bind the settings to control properties in the designer so you don't need any code at all.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    4

    Re: Writing Colors to a file?

    Quote Originally Posted by jmcilhinney View Post
    Don't use SaveSetting and GetSetting for anything.

    Open the project properties to the Settings page and add settings of type Color there. You can then access them via My.Settings in code. The data is loaded at startup and saved at shutdown automatically. You can even bind the settings to control properties in the designer so you don't need any code at all.
    I seen that too, but here is the thing. I have a context menu with menus that have different colors. Lets say I click blue it changes all my labels to blue. So could I do the way you just told me?

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,187

    Re: Writing Colors to a file?

    Absolutely. Like I said, you can bind your settings to your control properties so you need no code at all. You start the app and the setting is loaded from the config file and then bound to your control, which makes it appear as desired. You can update the setting value in code and all bound Labels will update automatically. The new value will then be saved automatically at shutdown.

    You use the (ApplicationSettings) property to bind properties to settings.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    4

    Re: Writing Colors to a file?

    Quote Originally Posted by jmcilhinney View Post
    Absolutely. Like I said, you can bind your settings to your control properties so you need no code at all. You start the app and the setting is loaded from the config file and then bound to your control, which makes it appear as desired. You can update the setting value in code and all bound Labels will update automatically. The new value will then be saved automatically at shutdown.

    You use the (ApplicationSettings) property to bind properties to settings.
    thanks got it

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