Listview question

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

Hi,
i have tabcontrol containing two tabPages. One of the tabPage contains
a ListView with dock property set to FILL. if i leave the default view
for the ListView.View property alone, i see the items i added (though
not the way i want them to appear), but if i change the view to DETAIL,
i see nothing. Anyone have any idea why this is happening?

so if i have:
this.ctlLv.View = View.Details;

ListViewItem lvi = new ListViewItem( "Dell" );
ListViewSubItem lvs = new ListViewSubItem( );
lvs.Text = "Dell Corp";
lvi.SubItems.Add( lvs );

ctlLv.Items.Add( lvi );

i do not see anything in the list view. but if i comment out the first
line, i do.
 
please not also, although i have not shown it in the code snippet
above, i am adding the columns using ColumHeader object and calling
ctlLV.columns.add( columnHeader).

I am trying this in Visual Studio 2005 beta 2
 
Hi Alex,
what do you mean by that? i have added two columns using
ctlLV.columns.add.

ColumnHeader ch = new ColumnHeader();
ch.text = "Name";
ctlLV.columns.add(ch);
ColumnHeader ch2 = new ColumnHeader();
ch2.text = "Description";
ctlLV.columns.add(ch2);
 
it appears i have to add the items first, then add the columns. i was
adding the columns first before. once i switched, it worked
 
and upon further inspection, the reason for this order is due to a bug
in my code. in my function that populates the listview,
instead of,
this.ctlLv.Clear();

i should have written,
this.ctlLv.Items.Clear();
 
Back
Top