473,379 Members | 1,542 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,379 software developers and data experts.

Binding Custom Collection/Objects

I'm new to .NET (using 2.0) and was wondering how to go about binding a
collection of custom classes to a DataGrid.

The class exposes 5 read-only String properties. I would like for each of
these properties to appear in a column in the DataGrid.

The end result would be that when the collection has 35 objects in it, the
DataGrid would have 35 rows and 5 columns (after being bound to the
collection).

Specifically -
1. which collection class could/should I use (or do I need to roll my own to
make it "bindable")?
and/or
2. how do I make my objects in that collection "bindable" to the DataGrid?

Thanks.
Sep 9 '06 #1
2 2202
Merk,

I would take a look into the BindingList<Tclass in the
System.ComponentModel namespace. It should provide most of the
functionality that you are looking for.

If you want to modify your objects from code, and have the grid update,
then you should probably implement the INotifyPropertyChanged interface on
your class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Merk" <A@B.COMwrote in message
news:et*************@TK2MSFTNGP05.phx.gbl...
I'm new to .NET (using 2.0) and was wondering how to go about binding a
collection of custom classes to a DataGrid.

The class exposes 5 read-only String properties. I would like for each of
these properties to appear in a column in the DataGrid.

The end result would be that when the collection has 35 objects in it, the
DataGrid would have 35 rows and 5 columns (after being bound to the
collection).

Specifically -
1. which collection class could/should I use (or do I need to roll my own
to make it "bindable")?
and/or
2. how do I make my objects in that collection "bindable" to the
DataGrid?

Thanks.

Sep 9 '06 #2
Yes - it helps a lot - exactly the level of direction I was looking for.
Thanks.
Sep 9 '06 #3

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

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
1
by: matty.hall | last post by:
There's a lot of information out there about data-binding UI objects (i.e. derived from Control) to non-UI custom business objects. Is it possible to do the same without any UI being involved at...
1
by: Conawapa11 | last post by:
I'm having trouble figuring this problem out and every example out there deals with simple objects within a custom collection. Take this example: public class ComplexClass { private int id;...
1
by: Demetri | last post by:
Someone posted the following back in June and I am now doing the same thing. I'll just paste what was asked and see if anyone can give us an answer: ...
3
by: JimGreen | last post by:
We are designing a WinForm application ( three tiered) There is a debate in our group as to whether we should pass datasets or our custom collections from business layer to the user interface...
0
by: Stephajn Craig | last post by:
I've built a customized collection class that has strongly typed objects in it. I have a collection class called LogEntryCollection with LogEntry objects in it. Each LogEntry object has certain...
1
by: Ruben | last post by:
I have a collection (PersonCollection inherits collectionbase and implements ITypedList it's a collection of Person objects) this collection also implements the IComponent interface, so I can drag...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
1
by: Suresh | last post by:
Using ASP.NET 1.1 ---------------------- I have a custom collection of object that I'm binding to a datagrid. Each of these objects have another collection inside them. I have a user control...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.