| 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; |
Code |
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.

jingeRank #2,527 · 554 reputationPosted Dec 9, 2009, 3:27 PM EST
you can control appending the Eviroment.NewLine when needed. or you can also add if-else statement to control when appending Enviroment.NewLine.
theLizardRank #1,079 · 1.8K reputationPosted Dec 9, 2009, 1:46 PM EST
for(int i =0; i< listView1.Items.Count; i++)
{
for(int j=0; j < listView1.Items[i].SubItems.Count; j++)
{
richTextBox1.Text = listView1.Items[i].SubItems[j] + Environment.NewLine;
}
}
If you have any problems formatting let me know...
Robert Mabrey7 reputationPosted Dec 9, 2009, 1:51 PM EST
jingeRank #2,527 · 554 reputationPosted Dec 9, 2009, 3:01 PM EST
Let me know if you have any difficulty.
Robert Mabrey7 reputationPosted Dec 9, 2009, 3:05 PM EST
jingeRank #2,527 · 554 reputationPosted Dec 9, 2009, 3:08 PM EST
Robert Mabrey7 reputationPosted Dec 9, 2009, 3:22 PM EST
ListViewSubItem: {0} ListViewSubItem: {robert} ListViewSubItem: {Evansville} ListViewSubItem: {112 Main st} ListViewSubItem: {in} ListViewSubItem: {76543} ListViewSubItem: {1} ListViewSubItem: {jane} ListViewSubItem: {113 main st} ListViewSubItem: {fr. branch} ListViewSubItem: {in} ListViewSubItem: {98765} ListViewSubItem: {2} ListViewSubItem: {Joe} ListViewSubItem: {114 Main st} ListViewSubItem: {louisville} ListViewSubItem: {ky} ListViewSubItem: {12345}