By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,581 Members | 1,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,581 IT Pros & Developers. It's quick & easy.

Creating a Custom Data Source that implements IList or IListSource

P: n/a
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...
Feb 9 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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)

--
-C. Moya
www.cmoya.com
Feb 9 '06 #2

P: n/a
CMM
Consider a DataTable a 2 dimensional array with a schema. That's all it
really is.

--
-C. Moya
www.cmoya.com
Feb 9 '06 #3

P: n/a
Hi,

Thanks for posting!

As Moya mentioned, the DataTable control is designed for the two dimension
data. One is the row and another is the column. Just for your reference:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclasstopic.asp

Creating a DataTable:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcreatingdatatable.asp

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

Feb 9 '06 #4

P: n/a
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

"CMM" wrote:
Consider a DataTable a 2 dimensional array with a schema. That's all it
really is.

--
-C. Moya
www.cmoya.com

Feb 15 '06 #5

P: n/a
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.

--
-C. Moya
www.cmoya.com
"Richard Bysouth" <sl***@nospam.nospam> wrote in message
news:03**********************************@microsof t.com...
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

"CMM" wrote:
Consider a DataTable a 2 dimensional array with a schema. That's all it
really is.

--
-C. Moya
www.cmoya.com

Feb 15 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.