Home All Groups Group Topic Archive Search About

Datagridview, object datasource, and hiding properties via attribu

Author
14 Sep 2006 4:28 PM
William Sullivan
I seem to remember this being possible, but I can't find a single thing about
it now..

I have a datagridview that is bound to a bindinglist of type 'foo'.  Foo is
a business object with a number of public attributes. 

I want to prevent the datagridview from binding to some of these public
attributes.  I can do it in the datagridview, but as I remember, there are
some attributes that I can apply to the public attributes in Foo that will
change how they bind to the datagridview.  Is my memory faulty?  If not, can
you give me some of the attributes so that I can search on those?  TIA.

It might be that I'm mixing up the datagridview with the property grid,
which does use reflection to examine the attributes of public properties in
the object that is bound to the property grid....

Author
14 Sep 2006 4:49 PM
Frans Bouma [C# MVP]
William Sullivan wrote:

Show quote
> I seem to remember this being possible, but I can't find a single
> thing about it now..
>
> I have a datagridview that is bound to a bindinglist of type 'foo'.
> Foo is a business object with a number of public attributes. 
>
> I want to prevent the datagridview from binding to some of these
> public attributes.  I can do it in the datagridview, but as I
> remember, there are some attributes that I can apply to the public
> attributes in Foo that will change how they bind to the datagridview.
> Is my memory faulty?  If not, can you give me some of the attributes
> so that I can search on those?  TIA.
>
> It might be that I'm mixing up the datagridview with the property
> grid, which does use reflection to examine the attributes of public
> properties in the object that is bound to the property grid....

    By default the BindingSource filters properties which have the
attribute Browsable(false) applied to them. You can set a different
attribute on the bindingsource if you want. Thought Browsable(false) is
pretty common for this.

        Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

AddThis Social Bookmark Button