473,569 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array question

I have a Jagged array that stores RoutingIDs and theirs corresponding Bank
Names.
I can access it as myArray[row][column]. The column index indicates whether
the value is RoutingID or a BankName.

myArray[0][0] - first bank's RoutingID
myArray[0][1] - first bank's Name
myArray[1][0] - second bank's RoutingID
myArray[1][1] - second bank's Name
....

Now I want to perform few operations on this array. But don't know what is
the best way.

1) I would like to display all Routing IDs in a combobox.
2) I would like to display all distinct Bank Names in another combobox.
NOTE: I need to display distinct Names. The array may contain same Bank Name
more than once with different Routing IDs.
3) When they select an item in either of the two comboboxes, I would select
their corresponding value in the second combobox.

Thanks.

Nov 16 '05 #1
2 2827
I would have to suggest switching from that jagged array to a DataTable.
First off, the DataTable can act as a small database, allowing sorting and
simple queries against it and will make it a lot easier to do things like
this. The trade off *might* be a bit more memory used for the DataTable and
also a bit more code to load it. But it should be easy to use the same code
that you are using to load your array.

Using the jagged array: (Note, I use ArrayLists for temp storage. I find
that they perform better than calling Array.Copy after every insert.)

To get all the Routing IDs:

<pseudo-code>
ArrayList tempArray = new ArrayList();
for(int r = 0; r < myArray.Length; r++)
{
tempArray.Add(m yArray[r][0]);
}
return (string[])tempArray.ToAr ray(typeof(stri ng));
</pseudo-code>

For getting all distinct bank names just do the same thing

<pseudo-code>
ArrayList tempArray = new ArrayList();
for(int r = 0; r < myArray.Length; r++)
{
if(!tempArray.C ontains(myArray[r][1]))
{
tempArray.Add(m yArray[r][0]);
}
}
return (string[])tempArray.ToAr ray(typeof(stri ng));
</pseudo-code>

For the third one, I think the FindString or FindStringExact method of the
DropDownList will get you what you need. You could also use the
SelectedIndex property if you are bound your array.

--
HTH

Kyril Magnos

Question of the day:
What is Mono?
A) Disease where the lymph nodes become swollen.
B) A single sound
C) A synonym for one
D) A port of .NET meant to royally irritate MSFT
E) All of the above.

"Nikhil Patel" <ni********@aol .com> wrote in message
news:eE******** ******@TK2MSFTN GP09.phx.gbl...
|I have a Jagged array that stores RoutingIDs and theirs corresponding Bank
| Names.
| I can access it as myArray[row][column]. The column index indicates
whether
| the value is RoutingID or a BankName.
|
| myArray[0][0] - first bank's RoutingID
| myArray[0][1] - first bank's Name
| myArray[1][0] - second bank's RoutingID
| myArray[1][1] - second bank's Name
| ...
|
| Now I want to perform few operations on this array. But don't know what is
| the best way.
|
| 1) I would like to display all Routing IDs in a combobox.
| 2) I would like to display all distinct Bank Names in another combobox.
| NOTE: I need to display distinct Names. The array may contain same Bank
Name
| more than once with different Routing IDs.
| 3) When they select an item in either of the two comboboxes, I would
select
| their corresponding value in the second combobox.
|
| Thanks.
|
|
|
Nov 16 '05 #2
Hi
1) I would like to display all Routing IDs in a combobox.
For that you should loop on the first index(lets say you will use a
variable int i for the loop)( and on that loop you add MyArray[i][0] to the
items collection of your combobox .
One more simple way to bind the combobox to the array and select the index
routingID as the display member

2) I would like to display all distinct Bank Names in another combobox.
This best done in a loop this time add MyArray[i][1] to the combobox
items collection , and you need to check for duplicate before adding the
item.
3) When they select an item in either of the two comboboxes, I
would select
their corresponding value in the second combobox.
You write a handler for selection changed event in both
combobox, for the first , you search for a match looping on MyArray[i][0]
and display the correspondence value at [i][1] , and the opposite would be
done in the other combo handler
hope that helps
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3

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

Similar topics

3
6394
by: SilverWolf | last post by:
I need some help with sorting and shuffling array of strings. I can't seem to get qsort working, and I don't even know how to start to shuffle the array. Here is what I have for now: #include <stdio.h> void main(void) { char lines; int count = 0, i;
9
2606
by: buda | last post by:
Hi, I've been wondering for a while now (and always forgot to ask :) what is the exact quote from the Standard that forbids the use of (&array) (when x >= number_of_columns) as stated in the FAQ 6.19 (http://www.eskimo.com/~scs/C-faq/q6.19.html). Thanks.
3
2685
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array is initialized with one element it works fine) But I can not change the initial state of the array. It must be null. what must I change.
11
2249
by: Geoff Cox | last post by:
Hello, I am trying to get a grip on where to place the initialization of two arrays in the code below which was created using Visual C++ 2005 Express Beta 2... private: static array<String^>^ LHSquestions = gcnew array<String^> {"question 1","question 2"}; private: static array<String^>^ RHSquestions = gcnew array<String^> {"question 1",
28
2421
by: anonymous | last post by:
I have couple of questions related to array addresses. As they belong to the same block, I am putting them here in one single post. I hope nobody minds: char array; int address; Questions 1: Why cannot I do the following:
104
16879
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this? Thanks.
51
23656
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc 10018-clc.c: In function `main': 10018-clc.c:22: warning: array subscript has type `char' I don't like warnings ... or casts.
7
6414
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are now thown out of the array released properly by the CLI?
8
1479
by: T. Wintershoven | last post by:
Hello all, I have a form with some checkboxes. The names of these checkboxes come from an array. When i click the submit button the resultcode doesn't recognize the names when i want to check wether or not some checkboxes are ticked. Assume that i tick checkboxes 100, 150 and 200 Below is some code i've used.(between the ****** lines)
4
4553
by: mab464 | last post by:
I have this code on my WAMP server running on my XP machine if ( isset( $_POST ) ) { for($i=0; $i<count($_POST);$i++) { if ($ans != NULL ) $ans .= ", " . $_POST ; // Not the first element so append a comma
0
7695
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...
0
7922
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
8119
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
7668
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...
0
6281
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...
1
5509
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
3653
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
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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

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.