Use subset of business class for use in list object

M

moondaddy

I'm wanting to create a bindable list object made up of a list of business
classes. I'm writing this in a vb.net 1.1 winforms app and am using a code
example by Rocky Lhotka for reference material:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet02252003.asp
which makes use of the IEditableObject interface.

My situation is that my business class manages data for a table which has
about 20 columns all of which are represented in the business class. In the
test samples I created from Rockies example, every property in the business
class became part of the bindable list so when I bound a my custom list
object to the datagrid, all 20+ columns showed in the datagrid. However, I
only want to use about 4 columns for the datagrid. I was wondering if there
was an elegant way to make a class that would be used as the ListItem class
and it would be an abstract of the business class and have only the columns
I wanted to use in the datagrid. Furthermore, I want to edit data from this
datagrid, so this ListItem class would need to utilize the New, Save,
Canceled, Delete, etc. methods from the business class with out having to
re-write a lot of extra code.

Can anyone recommend some good ways to approach this? and even better,
recommend some code examples or documentation?

Thanks.
 
C

Cor Ligthert

Moondaddy,

I am curious, do you want to make a business class which is directly
connected to even a special type of control from the UI?

Seems for me not directly the way to go,

However just my thought,

Cor
 
M

moondaddy

Thanks to both Cor and Dennis,

I'm using a 3rd party datagrid and I can't map select columns for the
binding. Also, I need to bind to a list of business objects so I can use
custom business logic during insert/update/deletes. I thought there would
be a good way to use inheritance or something, but that was more work than
it was worth, and by using inheritance, the grid bound to all of the
properties in the base class anyway. I ended up making a small class (lets
call it clsList for example) which referenced an instance of the business
class. clsList had only the properties I wanted to use in the grid and
utilized all the methods of the business class so there wasn't much to right
in it.
 

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