EnlightenedChair
EnlightenedChair

Reputation: 23

c# show Settings value in debug mode at runtime

Hello potential Readers

I wanted to know if one can see the stored value of a settingsobjet at runtime in debug. Like how you see the value of a variable if you hover above them. I know i could just always make :

string a = Properties.Settings.Default.(myObjectName) and hover over a, but I want to know if there is a quicker way. I already tried Google but it didn't really show me anything that answer my question:(

image of the settings

(i'm using visualstudios 2015 and .Net Framework 4.5.2).

Properties.Settings.Default.FileLocation = ProfileListBox.OpenFile;
//problem: I use the Filelocation quite often in my code but have to always backtrack to see what the currently assigned value for Filelocation is. 

If you know of an other way to see the Filelocationvalue (in my case) it would be very appriciated if you could tell.

Upvotes: 2

Views: 547

Answers (1)

frank
frank

Reputation: 1247

My be this approach helps you with your problem:

By simply handling the PropertyChanged Event of the Settings.

        void test() {
            Settings.Default.PropertyChanged += Default_PropertyChanged;
        }

        private void Default_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "MyProperty")
            {
                 var tValue = Settings.Default.PropertyValues[e.PropertyName].PropertyValue.ToString();
                 toolStripStatusLabelMessage.Text = String.Format("Property {0} changed to {1} ", e.PropertyName , tValue);
            }
        }

Upvotes: 2

Related Questions