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

Binding Strongly-Typed Collection to a Grid Control

I am trying to bind a strongly-typed collection to a data
grid on a windows form like:

BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataSource = inventory;

The grid doesn't show the records.Any idea??

Sefa

Nov 15 '05 #1
4 3967
Define "Strongly typed collection". How did you program this?

Otherwise - well - something is wrong with the colleciton OR the setup of
the grid.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)

"Sefa Sevtekin" <se******@de.ibm.com.removeSpam> wrote in message
news:05****************************@phx.gbl...
I am trying to bind a strongly-typed collection to a data
grid on a windows form like:

BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataSource = inventory;

The grid doesn't show the records.Any idea??

Sefa

Nov 15 '05 #2
Hi Thomas,

Thanks for your reply. Here is my strongly-typed
collection:

public class BeerInventory :
System.Collections.CollectionBase
{

public int Add(Beer value)
{
return List.Add(value);
}

public Beer this[int index]
{
get
{
return (Beer)List[index];
}
set
{
List[index] = value;
}
}
}
I don't think there is a flaw in collection. Anything that
I have to configure on Grid???

Thanks,
Sefa
-----Original Message-----
Define "Strongly typed collection". How did you program this?
Otherwise - well - something is wrong with the colleciton OR the setup ofthe grid.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)

"Sefa Sevtekin" <se******@de.ibm.com.removeSpam> wrote in messagenews:05****************************@phx.gbl...
I am trying to bind a strongly-typed collection to a data grid on a windows form like:

BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataSource = inventory;

The grid doesn't show the records.Any idea??

Sefa

.

Nov 15 '05 #3
Hi ,

It may sound silly, but did you call DataBind() after setting the
DataSource ?
I use a lot of such binding and until now I have never had any problem.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sefa Sevtekin" <se******@de.ibm.com.removeSpam> wrote in message
news:05****************************@phx.gbl...
I am trying to bind a strongly-typed collection to a data
grid on a windows form like:

BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataSource = inventory;

The grid doesn't show the records.Any idea??

Sefa

Nov 15 '05 #4

Whoops, sorry I did not see that part in the original post , I was thinking
of a asp.net grid :)

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Thomas Tomicek [MVP]" <t.********@thona-consulting.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
You dont have to call DataBind on a winform.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:eA****************@tk2msftngp13.phx.gbl...
Hi ,

It may sound silly, but did you call DataBind() after setting the
DataSource ?
I use a lot of such binding and until now I have never had any problem.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sefa Sevtekin" <se******@de.ibm.com.removeSpam> wrote in message
news:05****************************@phx.gbl...
I am trying to bind a strongly-typed collection to a data
grid on a windows form like:

BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataSource = inventory;

The grid doesn't show the records.Any idea??

Sefa



Nov 15 '05 #5

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

Similar topics

7
by: Ruslan Popov | last post by:
Hi, I am trying to prevent an assembly being loaded from GAC and instead want it loaded from the application's base directory. However, the assembly always gets loaded from GAC. How to have it...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
5
by: Oleg Subachev | last post by:
When I try to use strongly named assembly1 that references non-strongly named assembly2 I get the following error: "The located assembly '<assembly2 name>' is not strongly named." How can I...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
0
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions...
0
by: =?Utf-8?B?UnVzc2VsbCBQb29sZXk=?= | last post by:
I have a .NET 2.0 Web Service that is using a strongly named .NET 1.1 dll with a version of 1.0.1.0. If we change the version of the 1.1 dll that the web service is using to 1.0.2.0 we get an...
15
by: Tom Gur | last post by:
Hi, What is early/late binding ?
0
by: Dave Burns | last post by:
Hi, I have a C++ managed assembly (.dll) which links to a bunch of native libraries. Everything works fine if I don't make the managed assembly a strongly named one. Once I make it a strongly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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
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...

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.