Creating a Custom Data Source that implements IList or IListSource

G

Guest

Hi

I am trying to create an object that I can use to bind to a grid in my Win
app. All of the examples that I have found on custom data sources have the
properties (e.g. FirstNamer, LastName) of the objects making up the columns
in a grid. In my situation however there can be any number of columns.

I have created Row and Column classes, each of which have properties such as
Visible. Columns have a Caption property which should become the text in the
header cell of the grid.

I have built RowCollection and ColumnCollection classes which inherit
Generic List(Of Row/Column).

The missing link though is the class that holds the data values (and which
is bindable). As far as I can work out this would be say a Cell class, which
would have Row, Col and Data properties.

In the past (VB6 days) we were able to achieve this functionality using a
2-dimensional variant array e.g. GridData(Row,Col) - this could be bound
straight to the grid. So I guess what I need is the equivalent of that!

Can anyone point me in the right direction please?

thanks in advance...
 
C

CMM

This has already been done for you. It's called the DataTable.
DataTables (and Datasets) have nothing to do with "Databases."

Dim dt As New DataTable
dt.AddColumn("MyField")

Dim rw As DataRow = dt.NewRow()
rw.Item("MyField") = "whatever"

dt.Rows.Add(rw)
 
Y

Yuan Ren[MSFT]

G

Guest

Thanks very much - 2bhonest I think I must have been working too long
recently as this is obvious!! Have used DataTables many times before but (as
you imply) I was always thinking of them as related to Databases!

thanks
 
C

CMM

It's common. Very few developers can, in their mind, make the disconnection
between Datasets and databases (pun intended... get it? "disconnection").
Datasets are totally database-unaware. If anything, they're more related to
the System.Xml namespace than the System.Data namespace.
 

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