I am trying to use the built-in parameters of a .NET application. So, for example, I have a custom year parameter.
If the end user changes the setting in the program, I need to respond by updating the displayed data.
Currently, the following code is used for this:
Settings.Default.PropertyChanged += SettingsChanged; //on year change clear out the grid and update the data private void SettingsChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "year") { grdStudentCourseSearch.DataSource = null; grdStudentCourseSearch.DataMember = null; UpdateData(); } }
As you can see, they only seem to have an event handler for all parameters, and I need to use e.PropertyName to compare the strings to see which property has changed. Is there a better way to do this? Potentially, if I later change the names of the properties, this could be forgotten.
PeteT source share