Is there a reason why when using listview1.View = View.Details
my listview will expand (generate scrollbars) when I add items but have them be invisible, but when I switch it over to listview1.View = View.List
it works just fine?
Not that I think that it really matters, but here is the code that I use to add items to the listview:
ListViewItem item1 = new ListViewItem(file[1]);
listView1.Items.Add(item1);
And the autogenerated designer code:
//
// listView1
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Path});
this.listView1.Location = new System.Drawing.Point(12, 44);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(457, 354);
this.listView1.TabIndex = 7;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
file is a string array that contains about 50 odd characters in the first element (checked using debugger).
Are you calling "Clear"? If so make sure you are calling lv.Items.Clear()
and not lv.Clear()
.
The following code should work:
ColumnHeader columnHeader1=new ColumnHeader();
columnHeader1.Text="Column1";
this.listView1.Columns.AddRange(new ColumnHeader[] { columnHeader1 });
ListViewItem item = new ListViewItem("1");
this.listView1.Items.Add(item);
this.listView1.View = View.Details;
If it doesn't I have no clue. Are the characters of the string you are adding visible?
You need to add a column for Details view to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With