Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good Evening,

Hope some of you fine experts can assist me on this, i have an application that i need to save the settings in application settings which is fine however i need them to be exposed in the settings/config file on build.

No issues with normal settings however for each setting i need it to have 3 values, which are 'DDERow','DDECol' and 'DDELength'. there will be about 12 different settings and i dont want to have 12 * 3 settings.

i have been looking at adding custom types to the application settings but struggling to get this achieved by adding a custom type to the property.
VB
Imports System.Configuration

<SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _
Public Class DDESetting
    'BackBones
    Private _SettingDDERow As Integer
    Private _SettingDDECol As Integer
    Private _SettingDDELength As Integer

    Sub New()
    End Sub

    Public Property DDERow As Integer
        Get
            Return _SettingDDERow
        End Get
        Set(value As Integer)
            _SettingDDERow = value
        End Set
    End Property
    Public Property DDECol As Integer
        Get
            Return _SettingDDECol
        End Get
        Set(value As Integer)
            _SettingDDECol = value
        End Set
    End Property
    Public Property DDELength As Integer
        Get
            Return _SettingDDELength
        End Get
        Set(value As Integer)
            _SettingDDELength = value
        End Set
    End Property
    
End Class


i can now select this in my main application as a setting but it only shows a textbox to put a single value you in, how can i get it so i can add all 3 settings in on the settings page and then serialise it in the config file.

[EDIT]

Expected output:
XML
< settingname>
    <DDERow>
    <DDECol>
    <DDELength>
</settingname>


and i want to be able to access it via the normal My.Settings namespace so:

C#
My.Settings.SettingName.DDERow
My.Settings.SettingName.DDECol
My.Settings.SettingName.DDELength


[/EDIT]

Appreciate any help you can give.

I am using VS2010
Posted
Updated 19-Apr-15 19:49pm
v2
Comments
Maciej Los 19-Apr-15 16:53pm    
Could you be so kind and provide some more details about output xml data you want to achieve? Assuming issue description i suspect you want to use something like this: Public Property DDERow As List(of Integer). Am i right?
Dev O'Connor 19-Apr-15 17:06pm    
Hi There,

What i want to achieve this kind of format in my config file as follows:
< settingname>
<DDERow>
<DDECol>
<DDELength>
<!-- settingname-->

and i want to be able to access it via the normal My.Settings namespace so:

My.Settings.SettingName.DDERow
My.Settings.SettingName.DDECol
My.Settings.SettingName.DDELength

Maciej Los 19-Apr-15 17:17pm    
I'd suggest to read this: SettingsProvider Class[^], because of: "When you create a custom settings provider, at minimum, you must provide implementations for the three methods of this class: GetPropertyValues, SetPropertyValues and ApplicationName. "
Dev O'Connor 19-Apr-15 17:24pm    
Thank you for the info i will have a read of this.

I have never setup configuration files in this way before so new ground for me so i would appreciate any help you can give on this.

I have read a document and implemented sort of what i want, i have the class built and used a TypeConverter which outputs it as <settingname>1,1,1 but i would prefer it in more readable format with the different XML steps.

With it i override CanConvertFrom, ConvertFrom and ConvertTo but would like to have it in the format above.
Maciej Los 20-Apr-15 1:46am    
I've never use SettingsProvider before. So, i'm afraid i can't help you... ;(

1 solution

This was resolved using SettingsProvider
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900