Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Writting to a TextBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
C#Schroeder - 08 Nov 2006 19:29 GMT
I want to create an ArrayList of names ("Tony","Robin","Johnson") on
one page and then on another page I want to populate a TextBox field
with those names from the Arraylist.  How do I populate the TextBox?
Peter Duniho - 08 Nov 2006 19:46 GMT
>I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> one page and then on another page I want to populate a TextBox field
> with those names from the Arraylist.  How do I populate the TextBox?

Enumerate the list, forming a string from the names (using whatever
delimiters, if any, you desire of course), and then set the text of the
TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:54 GMT
The best way to enumerate the list is:
string[] names = (string[])list.ToArray(typeof(string));
textbox1.Text = string.Join("\r\n",names);

Ciaran O'Donnell

> >I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> > one page and then on another page I want to populate a TextBox field
[quoted text clipped - 3 lines]
> delimiters, if any, you desire of course), and then set the text of the
> TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:56 GMT
Or
object[] names = list.ToArray();
string.Concat(names);

this might be better because the arraylist doesnt copy the internal array
for this but the string.concat does a bit more work. This would use less
memory though.

Ciaran O'Donnell

> >I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> > one page and then on another page I want to populate a TextBox field
[quoted text clipped - 3 lines]
> delimiters, if any, you desire of course), and then set the text of the
> TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:59 GMT
Scrub this one, the ToArray() does copy the array so the other one is better.

> Or
> object[] names = list.ToArray();
[quoted text clipped - 13 lines]
> > delimiters, if any, you desire of course), and then set the text of the
> > TextBox to that string.
C#Schroeder - 09 Nov 2006 15:18 GMT
Thanks to everyone for the help.  It works
> Scrub this one, the ToArray() does copy the array so the other one is better.
>
[quoted text clipped - 15 lines]
> > > delimiters, if any, you desire of course), and then set the text of the
> > > TextBox to that string.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.