473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to create an userdefined data source object

Hello,

does anyone have for me a sample how to create an object, which has
access to any form of data and can be used as a data source for data
bound data grids.

In my case I've got a com object (GRecordset) which should become a
data source for a data grid.

Thank you,
Norbert
Sep 25 '08 #1
5 2766
For grids, the key thing is that the type should implement IList (or
IListSource, which provides indirect access to an IList), and ideally
the list should have a typed indexer (i.e. public SomeType this[int]
{get;}). That is enough for most common binding scenarios.

When things get more complex, it is possible to go deeper, using
ITypedList, or by implementing a CustomTypeDescriptor for the row-type
(SomeType in the above) - but the first thing to try is just implement
IList (or IListSource) on the collection-like object.

Marc
Sep 25 '08 #2
For info, in the case of a COM object, I would expect that you need to
write a wrapper object that implements IList, and either reads the data
into a local copy (List<Tfor some T), or which calls over to the COM
object as rows are requested. Each has advantages and disadvantages.

Marc
Sep 25 '08 #3
Hello
For info, in the case of a COM object, I would expect that you need to
write a wrapper object that implements IList, and either reads the data
into a local copy (List<Tfor some T), or which calls over to the COM
object as rows are requested.
this COM object called GRecordset (which looks like a DAO database
object) is not only for reading data. There are functions to write
data back. A List<Timplementation would only be a read-only data
structure. Do you have an idea how to implement a read/write data
structure to be used as data source for a data grid? What about the
DataSet object in C#? That would be the right data structure for a
data grid to show and save data. But how could I combine the
GRecordset with a C#- DataSet?

Thank you,
Norbert
Sep 26 '08 #4
I'm assuming that the GRecordset can have arbitrary columns?

In which case, it is one of the trickier scenarios; to enable direct
binding you'd have to implement a range of interfaces such as the tricky
ITypedList, and probably most of IBindingList etc. Not trivial, even if
you have done lots of ComponentModel work.

I would suggest that a more pragmatic approach might be to read your
data out of the GRecordset into a DataTable (just in a loop etc). Bind
to the DataTable; and when you are done, do the same thing in reverse to
copy the DataTable contents back over the GRecordset. Or *maybe* you
could go halfway by using events on the DataTable to perform updates as
they happen...

Marc
Sep 26 '08 #5
I wrote a demo for this on the train - not using GRecordset
specifically, but just a bespoke non-bindable table implementation, to
show how to wrap it in ITypedList etc. It is too long for this forum,
so I've e-mailed you instead. If you have a different address, e-mail
me back with alternative details.

Marc
Sep 26 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Guy Deprez | last post by:
Hi, i'm having a problem to create indexes. STEP 1 ----------- Connection is OK (you can find the string at the end of the message) Table ("Couleurs") creation is OK STEP 2. Index Creation
3
by: Daniel Lidström | last post by:
Hello, I want to have a class that contains only a collection of another class. For example: public __gc class Alignment { public: Alignment(); ... };
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
4
by: anthony.wolfe | last post by:
Hello all, I'm hoping that someone could help me with this bit of code. I am using reflection to dynamically call a method within an HttpHandler. When a method returns a user defined type that...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
1
by: mohins | last post by:
I am getting the error while I am trying to connect to Oracle with my code in ASP.NET, this code is working in another machine, but it fails in my laptop, giving the below error. Could not create...
0
by: Erwin Moller | last post by:
Hi group, I found something strange in PHP5.2.4 (on IIS7/Vista). I am working on an app that has been running just fine under heavy load for over a year at some custumer of mine. (they have...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.