473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding ArrayList full of custom objects to DataGrid

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 DataGridTableSt yle and set the MappingName to "ArrayList" . I
then add a DataGridTextBox Column for each of the properties in my custom
class which define a MappingName --> property name in class as well as
header text.
When I run the form, I see correct number of rows displayed, but none of the
columns appear. What am I missing?

Thank you in advance!

Berg

private void BindArrayListTo Grid(IList results)

{

searchResults.D ataSource = results;

DataGridTableSt yle ts = new DataGridTableSt yle();

ts.MappingName = "ArrayList" ;

int colwidth = (searchResults. ClientSize.Widt h

- ts.RowHeaderWid th

- SystemInformati on.VerticalScro llBarWidth - 5) / 2;

// Create a column for the "districtKe y" property

// defined in the districtKey Class

DataGridTextBox Column cs = new DataGridTextBox Column();

cs.MappingName = "districtKe y"; // Public property name

cs.HeaderText = "District Key";

cs.Format = "f4";

cs.Width = colwidth;

ts.GridColumnSt yles.Add(cs);

// Create a column for the "Telephone" property

// defined in the Telephone Class

cs = new DataGridTextBox Column();

cs.MappingName = "Telephone" ; // Public property name

cs.HeaderText = "Telephone" ;

cs.Format = "f4";

cs.Width = colwidth;

ts.GridColumnSt yles.Add(cs);

// Add the custom tablestyle to the DataGrid

searchResults.T ableStyles.Clea r();

searchResults.T ableStyles.Add( ts);

}
Nov 16 '05 #1
0 1684

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

Similar topics

5
2524
by: K | last post by:
I created a collection which is derived from ArrayList and implements IBindingList and ITypedList. Then I bound the DataSource of a data grid into the collection. It could show up the data but the column heading is not in the right order, for eg. I want "ID" column to be the first column but it showed as the second column. Another problem...
5
11186
by: Dalibor Kusic | last post by:
The DataTable contains, for example, only one column of lets say Person class. Person class has three fields, and a constructor that takes a single string and parses it over those three fields. Now, how do I modify the Person class (which interfaces to implement) so I can bind my DataTable to a DataGrid and then add, modify and delete...
3
5928
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 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 null and then...
0
1082
by: Terentius Neo | last post by:
I have binded a DataGrid to a custom hierarchy. It is an ArrayList of objects. Each object has a public property returning a new ArrayList of sublevel objects (which may again have sublevels of their own). All the objects are of the same base type. Everything works fine until there are no objects at the lower level. Despite this the link to...
5
1218
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 Username As String Public Password As String Public Email As String End Class
3
1573
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 refer to it as a DataField in an asp:BoundColumn? In essence, I'm doing this: ArrayList Arr1 = new ArrayList();
5
4855
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 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...
9
4680
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
2
2210
by: Merk | last post by:
I'm new to .NET (using 2.0) and was wondering how to go about binding a collection of custom classes to a DataGrid. The class exposes 5 read-only String properties. I would like for each of these properties to appear in a column in the DataGrid. The end result would be that when the collection has 35 objects in it, the DataGrid would have...
0
7839
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...
0
8202
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. ...
0
8338
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...
1
7959
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...
1
5710
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...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.