How to change options by enum

Nov 23, 2011 at 10:24 PM


I am trying to make a settings class for multiple types of databases. My issue is that different types of databases have different settings, så depending on which is chosen from the below enum, I would like a few settings to show, and others to not show.

    public enum DatabaseTypes { MySQL, PostgreSQL, MSSQL }

I have tried the VisibleBy annotation, but it seems to do nothing.

Jimmy Merrild Krag 

Nov 23, 2011 at 11:01 PM

Think I found out from 

Nov 23, 2011 at 11:10 PM

I have a feeling is has something to do with PropertyChangedEventHandler. I could use some help on that one.

Nov 23, 2011 at 11:17 PM

I have:

		[Category(Server), SortIndex(100), Browsable(true)]
		public DatabaseTypes Type { get; set; }

		public bool IsMySQL{ get { return Type == DatabaseTypes.MySQL; } }

		[Category(Settings), SortIndex(300), VisibleBy("IsMySQL")]
		public bool Option1 { get; set; }
		[Category(Settings), SortIndex(301), VisibleBy("IsMySQL")]
		public bool Option2 { get; set; }

but they don't react to changing Type

Nov 24, 2011 at 6:47 AM

Are you raising the INotifyPropertyChanged.PropertyChanged event on the IsMySQL property? This is neccessary!

In the examples I use NotifyPropertyWeaver to do the PropertyChanged notifications.

Nov 24, 2011 at 2:36 PM

Can you be a bit more specific? Where do I do that?

The only reference I can find to NotifyPropertyWeaver, is in a comment in TestBase.cs

Nov 24, 2011 at 4:16 PM

After some detectives work, I found out that I needed to add NotifyPropertyWeaver to my project, AND use a PropertyControl instead of a PropertyEditor.