473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(n ew Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(n ew Beer
("Budweiser" , "Anheuser-Busch", 1000));
inventory.Add(n ew Beer("Mulhollan d
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataS ource = inventory;

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

Sefa

Nov 15 '05 #1
4 3988
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.ib m.com.removeSpa m> 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(n ew Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(n ew Beer
("Budweiser" , "Anheuser-Busch", 1000));
inventory.Add(n ew Beer("Mulhollan d
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataS ource = 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.Collecti ons.CollectionB ase
{

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.ib m.com.removeSpa m> 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(n ew Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(n ew Beer
("Budweiser" , "Anheuser-Busch", 1000));
inventory.Add(n ew Beer("Mulhollan d
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataS ource = 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.ib m.com.removeSpa m> 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(n ew Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(n ew Beer
("Budweiser" , "Anheuser-Busch", 1000));
inventory.Add(n ew Beer("Mulhollan d
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataS ource = 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.********@tho na-consulting.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.mach in AT dot.state.fl.us > wrote in message
news:eA******** ********@tk2msf tngp13.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.ib m.com.removeSpa m> 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(n ew Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(n ew Beer
("Budweiser" , "Anheuser-Busch", 1000));
inventory.Add(n ew Beer("Mulhollan d
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;

dataGrid1.DataS ource = 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
11105
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 loaded from the application directory? I read about the bindingRedirect trick in the NG, however, specifying bindingRedirect did not work for me. Also, MSDN library states that "Application configuration files can have a codebase setting without...
1
7941
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 version of the MS Graph type library. Up until now I have been walking them through the process of setting the references to include their version of MS Graph library. My problem is that I can not seem to get the syntax correct .. or perhaps...
9
10430
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 As DAO.Workspace Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim rs As DAO.Recordset
5
1542
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 force strongly named assembly1 to reference non-strongly named assembly2 ? --
1
2634
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 Products table.
30
2839
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 integer The integers in these arrays are actually pointers to different columns of data in a text file.
0
2349
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 through internet explorer when hitting the ..asmx url, i cannot generate a proxy class to use in my winforms assembly. When i try to generate a proxy, i get no error message but nor do i get a reference.vb so there is no type info. If i then try...
0
989
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 expected type load exception when the webservice loads saying it wants the 1.0.1.0 version it was built with. This is fine, the problem we are having is if we provide assembly redirections in the Web Service to redirect the 1.0.1.0 to use 1.0.2.0 it...
15
3116
by: Tom Gur | last post by:
Hi, What is early/late binding ?
0
1578
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 named assembly by adding the following attribute: ;
0
9690
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
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10250
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
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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...
0
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
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.