473,472 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Binding DataGrid To ArrayList

Hey,
I Tried to bind a DataGrid to an ArrayList, and had 2 problems:
1. The DataGrid shows the Length property of the items instead of their
text - how can I change that?
2. After binding, I add new elements to the ArrayList but the DataGrid
doesnt refresh's it's view - I have to set the DataSource property of
the DataGrid to Nothing and then re bind it to the ArrayList! Isnt
there a "pretier" way?
Thanks ahead

--Rami

Nov 21 '05 #1
5 4841
Hi,

When you bind to an arraylist it will show the properties of the
class in the arraylist in the datagrid. It will not show public variables.
Here is an example.

http://www.onteorasoftware.com/downl...todatagrid.zip

Ken
---------------------
"Rami" <Ra*******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hey,
I Tried to bind a DataGrid to an ArrayList, and had 2 problems:
1. The DataGrid shows the Length property of the items instead of their
text - how can I change that?
2. After binding, I add new elements to the ArrayList but the DataGrid
doesnt refresh's it's view - I have to set the DataSource property of
the DataGrid to Nothing and then re bind it to the ArrayList! Isnt
there a "pretier" way?
Thanks ahead

--Rami
Nov 21 '05 #2
I've been developing a user control called MultiGrid which is editable that
binds to Arraylists, arrays, datatables, DataSets, and DataViews. It is not
an upgraded DataGrid but written from scratch. It binds to arrays and
Arraylists of classes (including public properties and public variables) as
well as Structures. Unfortunately, when you updata an arraylist or array in
code, you have to call an update method to reflect the changes in the gird.

You can edit the gird cells and they will reflect changes in the datasource.
However, It does change values in datatables, etc. but does not update the
unerlying DataBase. The user has to do this by code.

I don't have the documentation done yet but would be glad to send you the
assembly.dll and an example of how to use it. The various properties and
Methods are available in the Intelligentsense. I'd be happy to have someone
give it a try and let me know what they think. My e-mail is
dh*****@houston.rr.com. E-mail me if you're interested.

"Rami" wrote:
Hey,
I Tried to bind a DataGrid to an ArrayList, and had 2 problems:
1. The DataGrid shows the Length property of the items instead of their
text - how can I change that?
2. After binding, I add new elements to the ArrayList but the DataGrid
doesnt refresh's it's view - I have to set the DataSource property of
the DataGrid to Nothing and then re bind it to the ArrayList! Isnt
there a "pretier" way?
Thanks ahead

--Rami

Nov 21 '05 #3
Thanks for your reply - it really helped me!
But what about my second question - after dding new elements to the
ArrayList,
The DataGrid isnt refreshing automatically, is there a way to refresh
it's view so that it wills show the new items?
I Tried the Refresh and ResumeLayout Methods with no luck...
Thanks again,

--Rami

Nov 21 '05 #4
Hi,

Set the datagrids datasource to the arraylist to get it to
refresh.

Ken
------------------
"Rami" <Ra*******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Thanks for your reply - it really helped me!
But what about my second question - after dding new elements to the
ArrayList,
The DataGrid isnt refreshing automatically, is there a way to refresh
it's view so that it wills show the new items?
I Tried the Refresh and ResumeLayout Methods with no luck...
Thanks again,

--Rami
Nov 21 '05 #5
But wouldnt that restart the hole binding process all over again?
Isnt there a way to make the DataGrid refresh only the newly added
listItems or only the updated items?
Thanks again,

--Rami

Nov 21 '05 #6

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

Similar topics

1
by: Jordan | last post by:
After binding an arraylist to a datagrid, is it possible to allow the user to add and delete new rows on the datagrid just as they would if a datatable were bound to the control? I have tried to...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
2
by: John Sun | last post by:
Hi, Dear gurus, I want to bind my collection to a datagrid. The field names in my object show up in a weird order, and I just wonder how I could reorder those columns . I find some code like...
3
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add...
2
by: kids_pro | last post by:
I created a simple Person class as following: class Person{ private string fname; private string lname; public Person(string fname, string lname){ this.fname = fname; this.lname = lname; }
5
by: Alex Nitulescu | last post by:
Hi. I'm fighting the following code: __________________________________________________________________________ a. I have a class UserInfo.vb: <Serializable()> Public Class UserInfo Public...
3
by: Jim Bancroft | last post by:
Hi everyone, I'm binding an ArrayList to a DataGrid for the first time (I'm used to binding DataSets and DataTables) and I was wondering if I could somehow "name" the ArrayList, so that I can...
0
by: guy | last post by:
I have a winforms datagrid bound to an arraylist which works correctly, however if I add a row to the arraylist i cannot get the datagrid to display the updated data other than by:- clearing the...
16
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
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,...
1
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...
0
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
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.