2015-12-02 27 views
1

你好潛在讀者C#顯示設置值

我想知道,如果一個人能在調試運行時看到settingsobjet的存儲值。就像你看到一個變量的價值,如果你懸停在它們上面。我知道我可以總是:

string a = Properties.Settings.Default。(myObjectName)並將鼠標懸停在a上,但我想知道是否有更快的方法。我已經嘗試過谷歌,但它並沒有真正告訴我什麼,回答我的問題:(

image of the settings

(我使用visualstudios 2015年和.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.

如果你知道的另一種方式看Filelocationvalue(對我來說)這將是非常appriciated如果你能告訴。

+0

添加監視。在調試模式下,進入監視窗口,然後雙擊第一列中的空單元格。然後編寫Properties.Settings.Default。(myObjectName)並按回車。現在,當你點擊一個斷點時,你可以看到這個值。 – Lidaranis

+0

感謝您的回覆。可悲的是添加手錶給我錯誤CS1061或CS0103,我想不通爲什麼... – EternalCoder

回答

0

我的是這種方法可以幫助你與你的問題:

只需處理設置的PropertyChanged事件。

 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); 
      } 
     }