0

I am having issues with finding out exactly what my path forward should be. I would like to allow my users to be able to update the user scoped settings in the Settings.settings file in my application. I have created a form which displays these settings through a propertygrid. I would like to be able to show the description for each and maybe even assign them a category for better organization. Is there a good way to accomplish this?

Here is an example someone else had posted, but you have to make sure to include all settings. I would be afraid that I might miss one. my-settings-and-descriptions-and-getting-them-into-a-propertygrid

I guess that isn't the best reason to not use it. I also could not understand how to fully implement this option. There is also the other side of which I would like to be able to put the settings into a category instead of "Misc" like visual studio does by default.

Thanks for the help ahead of time.

J-Mo

  • *"I would be afraid that I might miss one"*. If that's a genuine concern then you may as well give up programming now because it's always possible that you'll miss something no matter what you do. *"I also could not understand how to fully implement this option"*. That's too vague to be of any use to us. Do what you can and then, when you encounter a specific issue, provide all the information relevant to that. That's what SO is for: specific issues. – jmcilhinney Sep 23 '19 at 23:40
  • Well as much as I appreciate your response, that was a little bit on the rude side. I am still learning. When I said, _"I would be afraid that I might miss one", I should have asked, **Is there a better way to accomplish this?**. I will continue on as I always have. I will research these boards, but I will stay away from posting. Thanks @jmcilhinney for your awesome answer. – DjJazzyJeffTN Sep 24 '19 at 17:42

1 Answers1

0

My Solution

My goal was to be able to display all of the user-scoped settings from the settings.settings file and allow the user to be able to edit them.

Settings Form Screenshot

I added the below code directly into the Settings.Designer.vb file. I know that moving forward I will have to add all of my settings manually so as to not regenerate the code.

The added lines were:

  1. Global.System.ComponentModel.DescriptionAttribute("Saves the location of the CMLs Form Location")
  2. Global.System.ComponentModel.CategoryAttribute("Location")
<Global.System.Configuration.UserScopedSettingAttribute(),
         Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),
         Global.System.ComponentModel.DescriptionAttribute("Saves the CMLs Form Location"),
         Global.System.ComponentModel.CategoryAttribute("Location"),
         Global.System.Configuration.DefaultSettingValueAttribute("0, 0")>
        Public Property FormCMLsLocation() As Global.System.Drawing.Point
            Get
                Return CType(Me("FormCMLsLocation"), Global.System.Drawing.Point)
            End Get
            Set
                Me("FormCMLsLocation") = Value
            End Set
        End Property

This will need to be completed for each property in the class.

The Property Grid in the form was limited to the User Scope with the below code.

Public Class FormUserSettings
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim userAttr As New System.Configuration.UserScopedSettingAttribute
        Dim attrs As New System.ComponentModel.AttributeCollection(userAttr)

        Dim myProxy As New ProxySettings

        If PropertyGrid IsNot Nothing Then
            'PropertyGrid.SelectedObject = myProxy
            PropertyGrid.SelectedObject = My.Settings
        End If
        PropertyGrid.BrowsableAttributes = attrs

    End Sub
End Class

Let me know if you have a better way of accomplishing this. It is not my preferred method with how much could go wrong.

-J-Mo