Populate a richTextBox from a listView

Dec 9 2009 6:01 PM
I'm trying to populate a richTextBox from a listView for the means of printing address labels
richTextBox1.Text = listViewPrint.SelectedItems[0].Text;
                        richTextBox1.Text = listViewPrint.SelectedItems[0].SubItems[0].Text;
                        richTextBox1.Text = listViewPrint.SelectedItems[0].SubItems[1].Text;
                        richTextBox1.Text = listViewPrint.SelectedItems[0].SubItems[2].Text;

The above code will only populate the richTextBox with text from the third column in the listView. If you remove the last line such that
richTextBox1.Text = listViewPrint.SelectedItems[0].Text;
                        richTextBox1.Text = listViewPrint.SelectedItems[0].SubItems[0].Text;
                        richTextBox1.Text = listViewPrint.SelectedItems[0].SubItems[1].Text;
                     
Only information from the second column is populated and so on. Is there a way to loop through this or maybe concatenate, or better code to use? Also I want it to format as follows
 Name
Address
City, State, Zip
Thank You!




Actually after more thought It isn't necessary to populate a richtextBox when I can print directly from the listView. how could I do this in the obove format and again the same issue as above with populating the textBox. it will onlt print the last column.

Answers (7)