Richtextbox -> ListBox
-
I have a problem when I try to copy the richtextbox text to the items in a listbox. Is there a way to stop it from placing the entire richtextbox text as 1 item. below is an example of what I mean. http://img456.imageshack.us/img456/1223/listbox8al.png
-
I have a problem when I try to copy the richtextbox text to the items in a listbox. Is there a way to stop it from placing the entire richtextbox text as 1 item. below is an example of what I mean. http://img456.imageshack.us/img456/1223/listbox8al.png
Split the string on \r or \n, whichever is the delimiter that's causing the boxes you see. You need to split the string, then insert it one line at a time. Christian Graus - Microsoft MVP - C++
-
Split the string on \r or \n, whichever is the delimiter that's causing the boxes you see. You need to split the string, then insert it one line at a time. Christian Graus - Microsoft MVP - C++
I did this and it seems to not be working, im stuck. myRTF = richTextBox1.Rtf; while (myRTF.Length > 0) { //Find the index of the RTF Return Character int index = myRTF.IndexOf("\r\n"); //Extract the RTF to that point string temp = myRTF.Substring(0, index); //Trim the extracted part of the RTF myRTF = myRTF.Substring(index, myRTF.Length - index); //Add the item to your list box listBox1.Items.Add(temp); }
-
I did this and it seems to not be working, im stuck. myRTF = richTextBox1.Rtf; while (myRTF.Length > 0) { //Find the index of the RTF Return Character int index = myRTF.IndexOf("\r\n"); //Extract the RTF to that point string temp = myRTF.Substring(0, index); //Trim the extracted part of the RTF myRTF = myRTF.Substring(index, myRTF.Length - index); //Add the item to your list box listBox1.Items.Add(temp); }
This is C#, your string class has a split method. Try splitting on just \r, or just \n. The boxes you get in your list box make me think the rich text control is returning one of those two, and not both. So, call the split method and get a string array, use for each to pass them into the list box. Christian Graus - Microsoft MVP - C++
-
This is C#, your string class has a split method. Try splitting on just \r, or just \n. The boxes you get in your list box make me think the rich text control is returning one of those two, and not both. So, call the split method and get a string array, use for each to pass them into the list box. Christian Graus - Microsoft MVP - C++
-
Just a sec, I'll whip up a project for you Christian Graus - Microsoft MVP - C++
-
Just a sec, I'll whip up a project for you Christian Graus - Microsoft MVP - C++
-
Your slash is the wrong way around. This works: string text = richTextBox1.Text; string [] strings = text.Split('\n'); foreach (string s in strings) { if (s.Length > 0) listBox1.Items.Add(s); } Christian Graus - Microsoft MVP - C++
-
Your slash is the wrong way around. This works: string text = richTextBox1.Text; string [] strings = text.Split('\n'); foreach (string s in strings) { if (s.Length > 0) listBox1.Items.Add(s); } Christian Graus - Microsoft MVP - C++