473,320 Members | 2,164 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,320 software developers and data experts.

Binding HashTable to datagridview

Hi,
I am using .net framework2.0,Visual Studio 2005.I need to bind the hash
table to datagridview.Is it possible
I am having class Person
class person
{
public int no;
public string name;
}

person a=new person();
a.no=100;
a.name="ffg";
I need to add obj a as both key and value
Hashtable ht = new Hashtable();
ht.add(a,a);
dataGridView1.DataSource = ht;
When I bind the Hashtable to datagridview,it is not showing anything in
datagridview.Is it possible to bind Hashtable to datagridview.Kindly
provide me the steps to bind hashtable to datagridview.

Regards,
Manikandan

Jun 29 '06 #1
2 10662
Try this:

dataGridView1.SelectionMode =DataGridViewSelectionMode.FullRowSelect;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ht;

chanmm

<pl**********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Hi,
I am using .net framework2.0,Visual Studio 2005.I need to bind the hash
table to datagridview.Is it possible
I am having class Person
class person
{
public int no;
public string name;
}

person a=new person();
a.no=100;
a.name="ffg";
I need to add obj a as both key and value
Hashtable ht = new Hashtable();
ht.add(a,a);

When I bind the Hashtable to datagridview,it is not showing anything in
datagridview.Is it possible to bind Hashtable to datagridview.Kindly
provide me the steps to bind hashtable to datagridview.

Regards,
Manikandan

Jun 29 '06 #2
Hi,
I tried the code as below

Hashtable ht = new Hashtable();
for (int x = 0; x < 10; x++)
{

Class1 a = new Class1();
a.a = x;
a.str = "ff";
ht.Add(a, a);
}
dataGridView1.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ht;

When i run the above code,nothing is diaplayed in
datagridView.DatagridView is empty only

Mani

chanmm wrote:
Try this:

dataGridView1.SelectionMode =DataGridViewSelectionMode.FullRowSelect;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ht;

chanmm

<pl**********@gmail.comwrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Hi,
I am using .net framework2.0,Visual Studio 2005.I need to bind the hash
table to datagridview.Is it possible
I am having class Person
class person
{
public int no;
public string name;
}

person a=new person();
a.no=100;
a.name="ffg";
I need to add obj a as both key and value
Hashtable ht = new Hashtable();
ht.add(a,a);

When I bind the Hashtable to datagridview,it is not showing anything in
datagridview.Is it possible to bind Hashtable to datagridview.Kindly
provide me the steps to bind hashtable to datagridview.

Regards,
Manikandan
Jul 3 '06 #3

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

Similar topics

3
by: abc my vclass | last post by:
There are some programs written on .NET 1.1. These applications are apply n-tiers contains Data Access Layers or Business Logic Layer. Now, our company upgrade to .NET 2.0 and enhance or rewrite...
2
by: Nathan | last post by:
Hi, I have a datagridview bound to a List of objects (ObjectA). Each ObjectA contains an ObjectB property. Class ObjectA { public ObjectB objB {} }
7
by: Nathan | last post by:
I'd like to use an enumeration as a datasource for a drop-down box. Is there a way to do this?
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
2
by: Bob | last post by:
Got a datagridview with records bound to tableParent. Each time I go to a new row (single select) in the datagrid view I want a series of textboxes as well as another datagridview to shwo the...
1
by: johnb41 | last post by:
I have some data in a hashtable, and i need to bind it to a combobox. I know it's impossible to bind a hashtable to a combobox. I need to "bind" it so the combobox gets a DISPLAYMEMBER and a...
3
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
New to databinding in vs2005, I always did it manually in 2003. I have no problem loading comboboxes, and a change in that combobox changes the data in the textboxes but I can not figure out a way...
11
by: dave18 | last post by:
Hello all! I found a solution to my original question, but there's still so much I don't understand about it, I thought I'd give this forum a try. At the very least, maybe it will help someone...
1
by: GS | last post by:
I am perplexed . I thought it is easy to fix the binding error on cvtDtFrom. I only used the cvtDtFrom a couple of places but I found out the error occurred before form loading. I tried...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.