How to change options by enum

Nov 23, 2011 at 9:24 PM

Hello

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.

--
Regards
Jimmy Merrild Krag 

Nov 23, 2011 at 10:01 PM

Think I found out from 

<!--StartFragment-->
TestVisibleProperties
<!--EndFragment-->
Nov 23, 2011 at 10: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 10:17 PM

I have:

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

		[Browsable(false)]
		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

Coordinator
Nov 24, 2011 at 5: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 1: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 3: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.