Well, here is a little snippet of code that perhaps may help you in your quest for inserting items in a listview....
In reality, a ListView is a way to sort data into columns/rows.
The first column of info contains the list view items, and other columns contain subitems (which are associated with each item).
<code>
public MyListView( )
{
//Create our ListView control...
ListView lv = new ListView();
lv.Parent = this;
lv.View = View.Details; //this just specifies how we view data in the listview.
//Create a new 'column' for our listview, named property. The 2nd argument set to -1, to autosize the column.
lv.Columns.Add( "Property", -1, HorizontalAlignment.Left );
lv.Columns.Add( "Value", -1, HorizontalAlignment.Left );
//Create our data to put in our listview.
string [] Properties = { "Property1", "Property2", "Property3" };
string [] Values = { "One", "Two", "Three" };
int iNumProps = Properties.Length; //Get number of props
for( int i = 0; i < iNumProps; i++ )
{
//Create a new listview item, which is the values to go in the 1st column.
ListViewItem lvi = new ListViewItem( Properties );
//Add subitems (things to second column), representing data for the values in the 1st column.
lvi.SubItems.Add( Values );
//Add the listviewitem to our listview
lv.Items.Add( lvi );
}
}
</code>
Now as you see, it's not too difficult, the for loop creates a new listview item each iteration, which makes the columns expand downward with each new value, the subitems make it increase in width... It's not too difficult to add more columns, or more subitems with listview items and subitems for each listview item. I hope this helps
The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)