| 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; |
|
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.
jingePosted Dec 9, 2009, 8:27 PM
you can control appending the Eviroment.NewLine when needed. or you can also add if-else statement to control when appending Enviroment.NewLine.
Robert MabreyPosted Dec 9, 2009, 8:22 PM
jingePosted Dec 9, 2009, 8:08 PM
Robert MabreyPosted Dec 9, 2009, 8:05 PM
jingePosted Dec 9, 2009, 8:01 PM
Let me know if you have any difficulty.
Robert MabreyPosted Dec 9, 2009, 6:51 PM
theLizardPosted Dec 9, 2009, 6:46 PM
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...