Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4606584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:35:11+00:00 2026-05-22T00:35:11+00:00

I am trying to implement a way of persisting a collection in a custom

  • 0

I am trying to implement a way of persisting a collection in a custom settings class. I have successfully created the settings class (inheriting ApplicationSettingsBase) and can save properties using the built-in editors on a PropertyGrid, but my custom implementation of a property grid for collections doesn’t persist any of the values I add. Here’s my code:

Imports System.Configuration
Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.ComponentModel.Design

Public Class CustomSettings
    Inherits ApplicationSettingsBase

    <UserScopedSetting()> _
    <DefaultSettingValue("White")> _
    Public Property BackgroundColor() As Color
        Get
            BackgroundColor = Me("BackgroundColor")
        End Get
        Set(ByVal value As Color)
            Me("BackgroundColor") = value
        End Set
    End Property

    <UserScopedSetting()> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    <Editor(GetType(CustomStringCollectionEditor), GetType(UITypeEditor))> _
    Public Property EmailAddresses() As Collection
        Get
            EmailAddresses = Me("EmailAddresses")
        End Get
        Set(ByVal value As Collection)
            Me("EmailAddresses") = value
        End Set
    End Property
End Class

Public Class CustomStringCollectionEditor
    Inherits CollectionEditor

    Public Sub New()
        MyBase.New(GetType(Collection))
    End Sub

    Protected Overrides Function CreateInstance(ByVal itemType As System.Type) As Object
        Return String.Empty
    End Function

    Protected Overrides Function CreateCollectionItemType() As System.Type
        Return GetType(String)
    End Function
End Class

I set a breakpoint on the Set methods for both the BackgroundColor property and the EmailAddresses property. The BackgroundColor property works as it should – it breaks on the Set statement and stores the property correctly. But when I close the custom CollectionEditor dialog, the EmailAddresses “Set” method is never called. How can I get my custom editor to actually save the property once it’s done being edited?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:35:12+00:00Added an answer on May 22, 2026 at 12:35 am

    I think I fixed it (with help from this question). I added an override to the EditValue function in my custom editor. Here is the code:

        Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
            Dim result As Object = MyBase.EditValue(context, provider, value)
            DirectCast(context.Instance, CustomSettings).EmailAddresses = DirectCast(result, List(Of String))
            Return result
        End Function
    

    I also moved from a collection to a list – I read somewhere that was a safer way to go. I also added a constructor to my CustomSettings class that set the EmailAddresses property to a new List(Of String) if it was unset to begin with. I found that the first time it ran, I could edit the list and add items, but they wouldn’t be persisted:

    Public Sub New()
        If Me("EmailAddresses") Is Nothing Then
            Me("EmailAddresses") = New List(Of String)
        End If
    End Sub
    

    And now it’s all working like it should. But if this isn’t the best way or there’s an easier way to do it, please chime in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a way to avoid click spamming. I have a
I'm trying to implement a generic way of adding remote validation to xVal /
I'm trying to implement a upload progress bar the HTML5 way, by using the
I'm trying to implement XOR in javascript in the following way: // XOR validation
I am trying to implement the SIR epidemic model . Basically, the way I
I am trying to find the best way to implement Model using Zend Framework
I'm trying hard to find a way to implement the Facebook api in cocos
I'm trying to figure out the most efficient way to implement RoR-style partials/collections for
I have been trying to understand the way ActionScript's events are implemented, but I'm
I'm trying to implement a way to animate (translate, fade) controls around (more than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.