Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to move string of any textbox ie = 1,2,45,178 to listbox in this format 1 2 45 178 itemwise output......in C# Web application

Please suggest some coding for the same
Posted
Comments
joginder-banger 19-Dec-13 13:40pm    
share you coding parts...for better understanding what's you want???
Adam Zgagacz 19-Dec-13 13:44pm    
Wouldn't
Textvalue.Replace(",", " ") be sufficient?

Compiler Error Message: CS0103: The name 'words' does not exist in the current context

Source Error:


Line 111:
Line 112: string[] splitedStr = text.Split(delimeterchars);
Line 113: foreach (string str in words)
Line 114: {
Line 115: ListBox5.Items.Add(str.ToString(), str.ToString());


Error in Line 113 please correct it........
 
Share this answer
 
Comments
Murugan Kolanji 19-Dec-13 14:54pm    
I changed my code.... can you check now

Line 113: foreach (string str in splitedStr)
Member 9975733 19-Dec-13 15:01pm    
Got it
You can use String.Split() method.


For example:

C#
// your case delimiter will be ','

     char[] delimiterChars = { ',' };

      string text = txtbox1.Text;// txtbox1 is treated your textbox

      string[] splitedStr = text.Split(delimiterChars);

      foreach (string str in splitedStr )
      {
          lstbox1.Items.Add(str.ToString(),str.ToString());  //lstbox1 as your listbox
      }
 
Share this answer
 
v2
Can't you use textbox.text.split(',') ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900