473,396 Members | 2,061 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,396 software developers and data experts.

databinding DataGrid to an IList object [reflection]

Hello,

I am thinking of a general solution to the specific issue and I hope
someone has some more experience on that.

Up to now I use the ListView as the primary control for collections of
items. Unfortunately, the ListView behaves sluggishly with large amounts of
data. That's why I think of using DataGrid instead.

The DataGrid in my application should be databinded to a memory
collection (could be an ArrayList or I could write my own collection).
Nevertheless, as far I as I know, the DataGrid's binding mechanism uses
reflection to ask for public properties in objects that was put into the
collection. That's exactly where the problem is.

Suppose I wish to populate a list where every row contains data from
several different objects. Or only few fields from one object. Or even some
additional data that does not belong to any class. What I need then is some
general mechanism that will allow me to add arbitrary "columns" and fill
columns with arbitrary data (just like you do with the ListView: at first
you add Columns and then add SubItems to each ListViewItem).

Unfortunately, I have no idea how I could mimic such behavior with the
DataGrid bounded to an ArrayList. I thought of a wrapper class that could
contain an array of values (for consecutive columns) but I do not know how
such class could not have a variable number of properties to feed the binder
correctly in various contexts. I do not want to create a separate wrapper
class for any context, of course.

The only solution I could think of is to build a temporary DataTable
with proper columns, copy the data from ArrayList to the DataTable and bind
the DataGrid to the DataTable.

Is there any other possibility that would not require a temporary
DataTable to be created?

Thanks for any suggestions.

Wiktor Zychla
Nov 16 '05 #1
0 2011

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

Similar topics

0
by: CGuy | last post by:
URGENT HELP REQUIRED FROM GURUS Hi, I have a custom object that implements ICollection and IListSource. This object has also an enumerator defined for it which implements IEnumerator and...
0
by: Sarfraz Hooda | last post by:
Hi, I have a collection object which i am binding to a ASP.Net datagrid. Columns are not appearing in the proper sequence as I would like it to appear on datagrid. I know I can modify the...
15
by: Rik Brooks | last post by:
I find it amazing that I am quickly able to find answers to obscure questions but simple ones elude me. I have a datagrid that I've bound, no problem at all. Now I want to - programatically -...
1
by: BB | last post by:
Hey, CollectionBase has following methods OnInsertComplete,OnSetComplete,.... When I bind a collection to a datagrid. Is it the datagrid thats call the OnInsertComplete? Or is it the List.Add...
3
by: Tom McLaughlin | last post by:
I am new to vb.net and I am running into problems understanding DataBinding and its concept. The only examples I find are always talk about Web design, I only want to use this data on my...
7
by: BS | last post by:
Hello everybody I'm calling a webservice that returns complex data. The goal is to populate a datagrid with it. Using a loop for each record found ( such as For i = 0 To...
13
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I...
1
by: suki | last post by:
How can i set the data binding property of an label to a field of a dataset (defined in a class in my project) ? In this data field, there are many entries and i want to have as much labels as...
4
by: Peted | last post by:
Hi I need to iterate through a winforms visible datagrid, in a legacy application, to update it a little bit to change the background colours of the grid. This seems to be more dificult than...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.