Results 1 to 5 of 5

Thread: [2005] Saving Custom Colors

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    [2005] Saving Custom Colors

    I have a colordialog box that I save the color last chosen using property bindings and My.Settings. My issue is that if they select and/or add a custom color, it doesnt remember the color added when I reload the program.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Saving Custom Colors

    Are you reading/loading the custom color from your saved settings?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: [2005] Saving Custom Colors

    You're either not loading the Color or not saving it because I just tested it and it worked perfectly. I started a new project, created a setting of type Color named "Colour", added a Panel and a Button to the form and then added this code:
    vb.net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     Me.Panel1.BackColor = My.Settings.Colour
    3. End Sub
    4.  
    5. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.     Using dialogue As New ColorDialog
    7.         If dialogue.ShowDialog() = Windows.Forms.DialogResult.OK Then
    8.             My.Settings.Colour = dialogue.Color
    9.             Me.Panel1.BackColor = dialogue.Color
    10.         End If
    11.     End Using
    12. End Sub
    Everything worked exactly as it should, whether I chose a standard or custom colour.
    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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: [2005] Saving Custom Colors

    I think you misunderstood my issue. The contol remembers the color. However the color dialog box does not remember the custom color. So if the user clicks on the color dialog box, his custom color cannot be selected by default because it is not there.

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

    Re: [2005] Saving Custom Colors

    Ah, I see. You are quite correct that the ColorDialog doesn't "remember" the custom colours. If you want that functionality then it's up to you to provide it. The ColorDialog has a CustomColors property that you can set before it's displayed and get after it's dismissed. If you want to save the custom colours and display them to the user in future then it's up to you to use that property and persist the colour values between sessions.
    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

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