Datagridview, object datasource, and hiding properties via attribu

G

Guest

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....
 
F

Frans Bouma [C# MVP]

William said:
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#)
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top