473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to iterate and display an Int Array list in a textBox? this has to be easy...

13 New Member
Ok guys,

I feel foolish here, but I have made a couple random hands of cards and wanted to see the full contents of those cards in a couple of textboxes.

But I suddenly realized that I am not sure how to do this?

If I loop through the twenty cards it will only show me the last one.

I need to concatenante it in an easy fashion. I KNOW that I could go simply do this:

string shuffledCards = myCards.arraylist[1].ToString() + myCards.arraylist[2].ToString() and on and on and on... and then place that string in a textBox....

BUT that cannot be the only way or even a good way to do it -- especially since I have 20 cards in each deck....can someone help me here?
Jun 27 '07 #1
2 1555
nateraaaa
663 Recognized Expert Contributor
Ok guys,

I feel foolish here, but I have made a couple random hands of cards and wanted to see the full contents of those cards in a couple of textboxes.

But I suddenly realized that I am not sure how to do this?

If I loop through the twenty cards it will only show me the last one.

I need to concatenante it in an easy fashion. I KNOW that I could go simply do this:

string shuffledCards = myCards.arraylist[1].ToString() + myCards.arraylist[2].ToString() and on and on and on... and then place that string in a textBox....

BUT that cannot be the only way or even a good way to do it -- especially since I have 20 cards in each deck....can someone help me here?
Have you considered using a loop to concatenate the array text into a string?

Expand|Select|Wrap|Line Numbers
  1. string shuffledCards = "";
  2. for(int i = 0; i < arraylist.Length; i++)
  3. {
  4. shuffledCards += shuffledCards + myCards.arraylist[i].ToString();
  5. }
  6. txtHands.Text = shuffledCards;
You may need to add spacing between each listed card in your textbox. I am not sure how you are wanting to display these to the user.

Nathan
Jun 27 '07 #2
tvance929
13 New Member
Awesome!

That almost worked perfectly!

I did have to change it a little (maybe this is just a c# thing) --- but I had to removed the shuffledCards out of your statement, because it added the same numbers over and over again.
you had :
shuffledCards += shuffledCards + fullDeck[i].ToString() + "\r\n";

had to make it:
shuffledCards += " " + fullDeck[i].ToString() + "\r\n";

BUT still, you really helped me and thanks a ton!
Jun 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1438
by: rbutch | last post by:
hey guys got a question. im trying to bind a textbox "at runtime". im creating the conn string, dataset, dataAdapter etc dynamically. and it keeps erroring out. <asp:TextBox ID="txtDay1"...
7
5039
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
3
25808
by: John | last post by:
i have lists with 10 and more textboxes for example test1.text, test2.text ....i want as i could do in vb6 with just a copy-paste of the same textbox, to have an array like test(1).text,...
10
2975
by: javuchi | last post by:
I just want to share some code with you, and have some comments and improvements if you want. This header file allocates and add and delete items of any kind of data from a very fast array: ...
0
2497
by: chongming | last post by:
Hi, i want to display all the filenames on browser. However i found that if there are many filenames in that folder, result will be it will display a long list of filenames on that browser. My...
25
25412
RMWChaos
by: RMWChaos | last post by:
Any JSON experts out there? I'd like to know if it is possible, and if so how, to iterate through a JSON property list so that each iteration selects the next value for each object. Here is an...
15
7711
RMWChaos
by: RMWChaos | last post by:
As usual, an overly-long, overly-explanatory post. Better too much info than too little, right? A couple weeks ago, I asked for some assistance iterating through a JSON property list so that my...
4
8853
by: im12345 | last post by:
I have the following question: Im doing a sample application using dojo and json. I have 2 classes: 1. Book class package com.esolaria.dojoex; import org.json.JSONObject; import...
3
2090
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a webform with several entry boxes and the user enters numbers in each box. I keep a running total (just adds all of the entries together) but am posting back to the server to do this. ...
0
7260
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,...
0
7161
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...
0
7539
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...
1
7101
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
7525
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...
0
5686
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,...
1
5089
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
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
802
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.