Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi...

 

I want to undestand how DataTable works when it presents data on a DataGrid.

So:

1. DataTable have 2 collections that interest me:

> Columns

> Rows

2. DataRow object have only one constructor and it's pivate.

This means that this object can only be created thru Reflection.

3. Inspecting a DataRow object at run-time, it seems that this object is, in fact, a collection, from where we van retrieve data thru index or name.

4. Now... How can we have a collection (Rows) witch each item is a collection (DataRow) and still the DataGrid can grab the column name and put it on the column header and grab the value and put it on the cell?

 

The closest I came to this scenario was to have a collection that implements IListSource and its items be a class with public properties.

This way, the DataGrid picks the property name as the column header caption and the property value for the cell...

 

This isn't quite the same, cause then I can't change the ColumnName like I can on the DataTable structure...

 

It seems that it gets the schema from the Columns collection and the data from the Rows collection... but how can this be donne?

 

 

Thanks in advance!

 

Alex :P

Software bugs are impossible to detect by anybody except the end user.
Posted
I'm not going to go into the details of your post, but you should note that whenever you make a DataTable the DataSource of a DataGrid, the grid is actually bound to a DataView, specifically the DefaultView of the DataTable.
Posted

Ok... now I'm on the right path...

 

The DataTable implements IListSource, so it has a GetList function that is the one that really returns the collection that is shown on the DataGrid...

I wasn't expecting to see that what DataTable hides behind the scenes is a DataView.

 

Yeah...

 

Now... why a DataView?

Simple... because it implements the real core interface that let it do what it does... ITypedList.

Simply put, ITypedList lets you present data based on 2 arrays, one for schema and the other one for data... just what I needed.

 

I'm gonna do some testing on that...

ITypedList have a GetItemProperties function that is a little tricky.

 

If anyone have any info abou ITyped List I can use I would be gratefull...

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...