Connecting Tech Pros Worldwide Forums | Help | Site Map

Use subset of business class for use in list object

moondaddy
Guest
 
Posts: n/a
#1: Nov 21 '05
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/de...et02252003.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.

--
moondaddy@nospam.com



Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Use subset of business class for use in list object


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


Dennis
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Use subset of business class for use in list object


Just create a tablestyle with only the columns you want to map to the DataGrid.

"moondaddy" wrote:
[color=blue]
> 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/de...et02252003.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.
>
> --
> moondaddy@nospam.com
>
>
>[/color]
moondaddy
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Use subset of business class for use in list object


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.

--
moondaddy@nospam.com
"Dennis" <Dennis@discussions.microsoft.com> wrote in message
news:98F04908-EBC9-45E9-BB13-4AB477ACF047@microsoft.com...[color=blue]
> Just create a tablestyle with only the columns you want to map to the
> DataGrid.
>
> "moondaddy" wrote:
>[color=green]
>> 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/de...et02252003.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.
>>
>> --
>> moondaddy@nospam.com
>>
>>
>>[/color][/color]


Closed Thread