473,770 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2033

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

Similar topics

0
2848
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 IList. Now, I'm trying to bind object to a combo box. The bidning happens correctly, but I'm unable to set the DisplayMember property of the combo box (the count of items in the combo box gives me the correct value, but no items are displayed in the...
0
1307
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 columns definition in data grid to change the order as I want and also by setting AutoGenerate columns to false. But I am wondering is there a way I can set the order at collection level? I have implemented the iList interface at collection.
15
9186
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 - loop through each row, extracting the data held in each column. I can't figure out how to do that. It has to be simple, can somebody please help me? --
1
1248
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 thats calling the OnInsertComplete? What I don't understand is when OnSetComplete is called
3
1537
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 standalone computer. So my question is: I have a sequential file that contains data and the data is structured. is there a way to load this data into a DataGrid control? If the answer is yes, then how do I accomplish this?
7
11930
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 oResponse.historicalData.Length - 1 ) no problem to load a datagrid. However, when I try to bind directly the datasource to the web service
13
5347
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 would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
1
2993
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 entries... Does the label duplicate automatically? How can i do that?
4
5587
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 i expected as it does not appear the DataGridRows collection is exposed with DataGrid. Is there a way to/ or best way to iterate through the rows of a
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.