Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListView Visibility issue 2

Status
Not open for further replies.

CodingIsFun

Programmer
Joined
Apr 9, 2004
Messages
134
Location
US
Hi all experts,


When I try to view this in Detail View its blank with no header and data. When viewed in list view it shows all my items. Is there a setting that I am forgetting to set, when this is in detail view

I have populated the listview(lstProducts) with the following code:

SqlDataReader dr = test.return_data_reader("usp_get_products_by_id", parameters, "products");

lstProducts.Clear();
lstProducts.View = View.Details;
if (dr.HasRows)
{
while (dr.Read())
{
ListViewItem item = new ListViewItem(dr["product_name"].ToString());
item.SubItems[0].Text = dr["dependent_product_id"].ToString();
lstProducts.Items.Add(item);
}
}
dr.Close();

Thanks in advance..
 
I figured out the problem.

I added the header column recreate after the clear and everything appears to be fine..

Thanks to everyone that was looking at this..
 
there's an easier solution - you're saying listview.clear() which says "Delete everything in my list view including columns, items, and values"

What you're looking for is lstProducts.Items.Clear();

this will save you adding in the columns every time!
 
Ah, that will certainly help.. Thanks..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top