473,657 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding HashTable to datagridview

Hi,
I am using .net framework2.0,Vi sual 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.D ataSource = ht;
When I bind the Hashtable to datagridview,it is not showing anything in
datagridview.Is it possible to bind Hashtable to datagridview.Ki ndly
provide me the steps to bind hashtable to datagridview.

Regards,
Manikandan

Jun 29 '06 #1
2 10696
Try this:

dataGridView1.S electionMode =DataGridViewSe lectionMode.Ful lRowSelect;
dataGridView1.A utoGenerateColu mns = true;
dataGridView1.D ataSource = ht;

chanmm

<pl**********@g mail.com> wrote in message
news:11******** **************@ d56g2000cwd.goo glegroups.com.. .
Hi,
I am using .net framework2.0,Vi sual 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.Ki ndly
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.S electionMode =
DataGridViewSel ectionMode.Full RowSelect;
dataGridView1.A utoGenerateColu mns = true;
dataGridView1.D ataSource = ht;

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

Mani

chanmm wrote:
Try this:

dataGridView1.S electionMode =DataGridViewSe lectionMode.Ful lRowSelect;
dataGridView1.A utoGenerateColu mns = true;
dataGridView1.D ataSource = ht;

chanmm

<pl**********@g mail.comwrote in message
news:11******** **************@ d56g2000cwd.goo glegroups.com.. .
Hi,
I am using .net framework2.0,Vi sual 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.Ki ndly
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
7237
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 the applications. In ..NET 1.1, we favour to return DataTable from DAL or BLL and then press to datagrid's datasource and to bind data. Now, I think .NET 2.0 have some difference to bind data. Is there any good example let me to know how to...
2
16335
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
4452
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
11463
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 in datagridview2 that corresponded to a selected row in datagridview1. Great article/example.
2
1433
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 realted records. The textboxes are in tableChild1 and the other datagridview is of tableChild2, Both these tables have a PK-FK relationship established in the dataset being used. How can I do this? Any help appreciated. Bob
1
4064
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 VALUEMEMBER. I can't supply a valuemember by simply iterating through a hashtable and adding items to a combobox. How else can i get the same effect? What's the best way? If not a hashtable, what type of object should I use? (i'm currently using...
3
6320
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 to get the data in a datagridview to change. For example 2 columns are ID and amount_paid, the datagridview loads on form load with all ID's and amounts. How do I get it to only bring back the selected ID. Sounds like I may need to change the SQL...
11
76166
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 else who got stumped like I did. It seems so simple... binding a DataGridView to a List<T>. These are the two general problems that I kept running into: (1) When the data in the list updated, the data on the screen did not update. (2) When I...
1
2101
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 searching in the solution for cvtDtFrom but failed to find the culprit. tried using clue from stack trace, searching for DataGridview and variations of view.datacon... no luck, Even tried searching all files for the sub main, I failed to find...
0
8421
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
8325
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,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1971
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.