Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 12th, 2006, 4:44 PM   #21
Jason Isom
Programmer
 
Join Date: Dec 2005
Posts: 53
Rep Power: 3 Jason Isom is on a distinguished road
Quote:
Originally Posted by crawforddavid2006 View Post
I lied... that is not the end of my problems . What Jason said does work but it leaves a little rectangle shape after each line. I tried using \b after the \n but it will not accept that. Any Ideas?
Are you using .NET 2.0? If so:

csharp Syntax (Toggle Plain Text)
  1. comboBox1.Items.AddRange(System.IO.File.ReadAllLines(@"c:\collection.txt"));

This isn't the only solution, however. In .NET, the newline is encoded as Environment.NewLine (usually \r\n).

csharp Syntax (Toggle Plain Text)
  1. string s = System.IO.File.ReadAllText(@"c:\collection.txt");
  2. string[] delimiters = new string[1];
  3. delimiters[0] = Environment.NewLine;
  4. comboBox1.Items.AddRange(s.Split(delimiters, StringSplitOptions.None));

Which can be shortened to:

csharp Syntax (Toggle Plain Text)
  1. string s = System.IO.File.ReadAllText(@"c:\collection.txt");
  2. comboBox1.Items.AddRange(s.Split(new string[]{Environment.NewLine}, StringSplitOptions.None));
Jason Isom is offline   Reply With Quote
Old Sep 12th, 2006, 9:36 PM   #22
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
There's an AddRange function? Funky.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 12th, 2006, 9:48 PM   #23
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Thanks Jason. your idea for .NET 2.0 worked.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jun 4th, 2007, 1:31 AM   #24
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
ok I can't figure out for the life of me how to write all the items in a combo box to a text file, can someone help me with this please?
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jun 4th, 2007, 2:35 AM   #25
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Probably I should ask how exactly did you try .. but nevermind that :

try :
csharp Syntax (Toggle Plain Text)
  1. comboBox1.Items.Add("asdasd");
  2. foreach (Object o in comboBox1.Items)
  3. {
  4. MessageBox.Show(o.ToString());
  5. }
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jun 4th, 2007, 3:09 AM   #26
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
i'm a little confused, how does that write the items in the comboBox to a text file?
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jun 4th, 2007, 4:43 AM   #27
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Quote:
Originally Posted by crawforddavid2006 View Post
i'm a little confused, how does that write the items in the comboBox to a text file?
well that gives you the items in the comboBox, i suppose you know how to write to a text file. How about showing some code ?:beard:
I was under the impression that you couldn't get the items from the combo.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jun 4th, 2007, 3:30 PM   #28
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Well i can get them, but when i write them to the file it says "System.Windows.Forms.ComboBox+ObjectCollection" in the text file, not the items.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jun 5th, 2007, 4:14 AM   #29
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Ok mate . I'm assuming you have strings in that comboBox, otherwise you will have to do a cast to the object that is in the Combo.

csharp Syntax (Toggle Plain Text)
  1. // instantiate the writer class : let's say writer
  2. foreach (Object o in comboBox1.Items)
  3. {
  4. writer.Write(o.ToString); // or ((YourObject)o).ToString(); - if it's not a base type
  5. }

If it doesn't work, just post the code.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jun 5th, 2007, 9:33 PM   #30
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
sorry i forgot to post after my last one, i found a way to do it, so thanks for all your help.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
3 language combo. Nebula Coder's Corner Lounge 9 Dec 19th, 2005 1:34 PM
anoying problem with a combo box cloud- Visual Basic 12 May 28th, 2005 1:20 PM
Java Combo Boxes Vengeance Java 0 May 4th, 2005 9:02 AM
What are advantages of Data Combo and data list over simple combo and list box? sham Visual Basic 1 Apr 12th, 2005 4:11 AM
combo box in form.. cloud- HTML / XHTML / CSS 5 Mar 15th, 2005 3:21 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:40 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC