|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating a Custom Data Source that implements IList or IListSourceI 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... 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) Consider a DataTable a 2 dimensional array with a schema. That's all it
really is. 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 Show quoteHide quote "CMM" wrote: > Consider a DataTable a 2 dimensional array with a schema. That's all it > really is. > > -- > -C. Moya > www.cmoya.com > > > 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. Show quoteHide quote "Richard Bysouth" <sloth@nospam.nospam> wrote in message news:0382BDBC-7802-4B19-B3AF-0A22F595AC87@microsoft.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 >> >> >> 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/default.asp?url=/library/en-us/cpref/html/ frlrfsystemdatadatatableclasstopic.asp Creating a DataTable: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm l/cpconcreatingdatatable.asp Regards, Yuan Ren [MSFT] Microsoft Online Support |
|||||||||||||||||||||||