Click here to Skip to main content
15,898,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a listview control on my form with View property set to List.
listView1.View = View.List

I ask user to chose an item from listview and then displays a confirmation message box whether to save item chosen in listview.
If user says Yes, then item is saved and the controls on the form(a textbox, a listview) was cleared to allow user to save new items.
*(For some reasons, I need to clear items in the listview first, before asking user to save another item)

I am populating list at runtime and the size of listview is wide enough to display items completely in a single row.

On first run: items were added to listview normally i.e., text for each item was completely visible)
On second run: list was first cleared and repopulated with same items. This time, text for each item was not completely visible, instead text was trimmed after a certain length of characters and an ellipsis was placed.

Also, no data bindings are done for the list.
I tried googling about the issue, but didnt find anything.

What I have tried:

listview.Refresh();
listview.RedrawItems(parameters);
Posted
Updated 25-Feb-16 21:45pm

1 solution

If your list is the same you do not need to clear and repopulate, set selectedindex = -1 to set it to no selected item.

See: ListView.SelectedIndex Property (System.Web.UI.WebControls)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900