none
How can I get the configuration property value? RRS feed

  • Question

  • Best regards:

    I have the following code, but I want get the actual configuration property value, NOT the default value.

    How can I change my code?

    Dim df As System.Configuration.SettingsProperty
    For Each df In My.Settings.Properties
     If df.Name = Me.AR_Unit.ToString Then
      If df.DefaultValue = True Then
       Dim NIA As New ListBoxItem() : Dim NIB As New
       ListBoxItem()
       NIA.Content = registro : NIB.Content = registro
       PR03.Items.Add(NIA) : PR05.Items.Add(NIB)
       AH = AH + 16.3466666666667
      End If
     End If
    Next

    Thursday, February 23, 2012 9:58 PM

Answers

  • Do you mean you have change the setting value from other code? For example, there is a property setting names myColor, it has a default value, but you have change the value like this:

    Properties.Settings.Default.myColor = Color.AliceBlue;
    

    But when you read the value of myColor, it still returns default value, but not Color.AliceBlue. Is this your case?

    If yes, do you ensure that you have saved the value after changing it.

    Please refer to:

    http://msdn.microsoft.com/en-us/library/aa730869(v=VS.80).aspx


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Paul Zhou Friday, March 2, 2012 4:16 AM
    Tuesday, February 28, 2012 6:58 AM

All replies

  • Replace this line:

     If df.DefaultValue = True Then

    for this

     If df.DefaultValue = False Then

    Good Luck


    ...

    Sunday, February 26, 2012 2:40 PM
  • Do you mean you have change the setting value from other code? For example, there is a property setting names myColor, it has a default value, but you have change the value like this:

    Properties.Settings.Default.myColor = Color.AliceBlue;
    

    But when you read the value of myColor, it still returns default value, but not Color.AliceBlue. Is this your case?

    If yes, do you ensure that you have saved the value after changing it.

    Please refer to:

    http://msdn.microsoft.com/en-us/library/aa730869(v=VS.80).aspx


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Paul Zhou Friday, March 2, 2012 4:16 AM
    Tuesday, February 28, 2012 6:58 AM