all groups > dotnet windows forms databinding > april 2008 >
You're in the

dotnet windows forms databinding

group:

Hide data object property


Hide data object property Rick
4/10/2008 8:18:34 AM
dotnet windows forms databinding:
VS2005 pro

The short question is this: How do I hide public properties of my class from
binding in a datagrid for example. Setting <Browsable(false)> will not work
since I have to bind to these properties in some win forms. In need the
property available when binding, but not to display in grids.

Here is the detail:

I have custom data classes for my business objects. Amoungst the properties
are other "nested" child objects like this:

Class Invoice
public property ID as Integer
get ...
set ...
end property

... more properties

public readonly property InvItems as InvoiceItems
get ...
end property
end class

Normally I would have a BindingSource bound to Invoice and then another
BindingSource bound to Invoice.InvItems.

All is ok so far, but when I load this object into a DataTable the InvItems
object is included which I do not want. I can get rid of it by deleting the
Column, but I would rather do it in the object itself using an attribute.

I have tried to set the unwanted property with the attribute
<Browsable(False)>, but then I cannot bind to it at runtime. So I need some
other attribute or method to acomplish this.

The only thing I can think of is a custom attribute.

Any other ideas?

Regards,

Rick

AddThis Social Bookmark Button