473,666 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid displaying related ArrayLists

Hi,
I have two classes, Department and Employer, the Department contains an
ArrayList (employers) filled with Employer objects. I want to display an
ArrayList filled with Department objects using a Datagrid. Therefor, I do a
setDatabinding with the Deparments ArrayList and I create two
DatagridTableSt yle objects, both with mappingname "ArrayList" , and add them
to the Datagrid. However, if I want to add the second DatagridTableSt yle, I
get the exception that a table with mappingname "ArrayList" already exists
(makes sense). If I change the Deparment ArrayList to a strongly type array
Department[], and change the mappingname accordingly all works well, of
course. (great feature by the way). I want to know whether it is possible to
display this kind of objectstructure using just ArrayLists.

kind regards,
Christiaan
Nov 15 '05 #1
4 1614
Hi Christiaan,

Thanks for posting in the group. We are currently researching on this issue
and will update your ASAP.

If there is anything unclear, please feel free to post in the community and
we will follow up.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 15 '05 #2
thnx, I would appreciate that!

"Kevin Yu [MSFT]" <v-****@online.mic rosoft.com> wrote in message
news:L#******** ******@cpmsftng xa07.phx.gbl...
Hi Christiaan,

Thanks for posting in the group. We are currently researching on this issue and will update your ASAP.

If there is anything unclear, please feel free to post in the community and we will follow up.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 15 '05 #3

Hi Christiaan,

Thank you for posting in the community!

Based on my understanding, you want to specify 2 ArrayLists of
DatagridTableSt yle for the same datagrid.

=============== =============== ============
If you want to bind your datagrid to arraylist object, all items in the
arraylist must be of the same type as the first item. And when binding to
an ArrayList, you must set the MappingName of the DataGridTableSt yle to
"ArrayList" (the type name).

In the document of GridTableStyles Collection class, you will see that:
"CAUTION ...... Consequently, an exception will be thrown if you try to
add new DataGridColumnS tyle objects with duplicate MappingName values to
the GridColumnStyle sCollection. Alternatively, clear the
GridColumnStyle sCollection using the Clear method."
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwind owsformsgridtab lestylescollect ionclasstopic.a sp

So DataGrid.TableS tyles does not support 2 DatagridTableSt yles with the
same MappingName.

I think your workaround of using array is a simple and good.

Another workaround I can think of is creating a new class which inherited
from the ArrayList class, then you can specify different MappingName.

=============== =============== ==============
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4

Hi Christiaan,

Does my reply make sense to you?
If you still have anything unclear, please feel free to tell me, I will
help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

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

Similar topics

3
3047
by: Stephen | last post by:
I've got a datagrid with a remove button and I would like to add some code in the code behind page so as whenthe button is clicked the corresponding row in the datagrid is removed. The Datagrid is populated by the items in an arraylist shown in the code below. When the button is clicked I would also like the code to remove the items from the Arraylist. I've very little experience working with datagrids and arraylists so im finding this...
0
306
by: Christiaan | last post by:
Hi, I have two classes, Department and Employer, the Department contains an ArrayList (employers) filled with Employer objects. I want to display an ArrayList filled with Department objects using a Datagrid. Therefor, I do a setDatabinding with the Deparments ArrayList and I create two DatagridTableStyle objects, both with mappingname "ArrayList", and add them to the Datagrid. However, if I want to add the second DatagridTableStyle, I get...
2
1339
by: pmcguire | last post by:
I have a form displaying information from one record in a datatable and a datagrid displaying "child" information from records in another, related, datatable. I have added a DatagridTableStyle so that the relevant foreign key is not displayed in the datagrid. How do I automatically insert the foreign key value into the child record upon row insertion in the datagrid It seems I need an OnInsert eventhandler for either the child datatable or...
1
927
by: Chuen | last post by:
Hi, If I use datagrid to operate dataset, my problems is how to display a column value with its related other value. I means: suppose there are two tables in dataset, table1: id name 1 "IBM" 2 "Microsoft" 3 "ASUS" Table2: id, Date, Qty, note
5
4856
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 then re bind it to the ArrayList! Isnt there a "pretier" way? Thanks ahead
16
2018
by: stojilcoviz | last post by:
I've a datagrid whose datasource is an arraylist object. The arraylist holds many instances of a specific class. I've two questions about this: 1 - Is there a way by which I can obtain a reference to the arraylist item the current row points to? 2 - Is it possible to sort the grid? Many thanks in advance.
1
1241
by: jwogick | last post by:
I'm hoping someone can help me! I just have a simple form with a datagrid displaying child records from a dataset that contains two related tables Parent table>Clients Child table>cases. using the designer I tell the datagrid to display the child records only from the dataset (Relation called ClientsCases table>cases) it will display the data fine but when I add a new tablestyle with custom columns it does not change the columns in the...
6
5737
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
0
2071
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the end of this message, but I will start with an overview of the problem. I've made a content management solution for my work with a decently structured relational database system. The CMS stores articles. The CMS also stores related items --...
0
8356
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
8869
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...
1
8551
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
8639
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
7386
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
4198
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
2011
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.