Hiding members for the DataSource window
Mon, Oct 17 2005 12:17
The new DataSource window in VS.NET 2005 truely rocks ! I love how you can have all different kinds of data sources in there, be it your web services, data from your database or *ANY* type in your project including, of course, your business objects.
So when you do add business objects to the DataSource window, you may find it shows properties you don't want people to bind to, yet you still want them to be able to access those peoperties in code. The solution is very simple. Simply mark the properties with the:
attribute, and they won't show up in the Datasource window and the binding source will throw an error if they are attempted to be bound against.
What I found really nice was I had an abstract base class (MustInhertit) with some abstract properties defined in it (MustOverride) and applying the attribute there in the base class cascaded through nicely to all derived classes. Of course the derived classes with their Overrides in them could re-appy the attribute setting it to either True or False, to show or hide the property respectively . sweet