473,473 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using List<object> as a datasource, how??

..NET 2.0

I'm wondering if it is possible set the DataGridView.DataSource to a
List<objectcollection. Where object is a class derived from the object
class.

If it's possible then my question is how?

I ask becasue I think it's much better to use the collection directly than
performing a foreach statement adding the rows to the DataGridView...

any suggestions?

Jeff
Jul 17 '07 #1
2 1852
Suggestion: BindingList<T>


"Jeff" <do***@spam.mewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
.NET 2.0

I'm wondering if it is possible set the DataGridView.DataSource to a
List<objectcollection. Where object is a class derived from the object
class.

If it's possible then my question is how?

I ask becasue I think it's much better to use the collection directly than
performing a foreach statement adding the rows to the DataGridView...

any suggestions?

Jeff

Jul 17 '07 #2
Any list (IList (*)) can be used as a data source, even plain
ArrayList. The binding works much better if the collection implements
a typed indexer "T this[int]", which List<Tdoes (**) - this allows
it to ask for the properties of the type, via TypeDescriptor. And
better again if it supports the binding interfaces like IBindingList,
IBindingListView - hence BindingList<Tis your best bet (as per
Fred's post).

Just some background.

[* aside: or something that exposes a list via IListSource]
[** aside: ITypedList performs a similar role to a typed indexer, but
is more complex to implement]

Marc
Jul 17 '07 #3

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

Similar topics

0
by: Dominator.Legend | last post by:
Hallow every one, i have a problem using .net user control with the <OBJECT> tag, I made a normal user control in C#, then i use the regasm to register it, also i use the option regfile to...
4
by: colson | last post by:
Hi, If I have a class A, and a List<List<object>> containing instances of A. How do I explicitly cast List<List<object>> as List<List<A>>?
13
by: Murat Ozgur | last post by:
Hello, Is there any difference between ArrayList and List<object? Which one should I use ? Thanks.
9
by: Stephan Steiner | last post by:
Hi I seem to have a bit of trouble understanding one bit of how generics work: In C#, every class automatically derives from object, and inherits a bunch of properties (i.e. ToString()). Thus,...
0
by: chiara85 | last post by:
How can I incorporate a video using this script? Can I use this script for different kind of files (AVI, MPG…?) <object data= "media/video-sample.avi" type="video/avi" />
5
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a list of type object. The object has an ID as one of the elements and I would like to create another list that just has objects with unique IDs. For example in the list if I have...
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
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,...
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.