Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

.NET Listview & C#

Options
  • 12-11-2003 12:44pm
    #1
    Registered Users Posts: 7,468 ✭✭✭


    I'm refreshing a listview from within my C# application. The problem is the refresh doesn't take place. I've tried clearing the listview items using .Clear() and .Items.Clear(). The adding all the items again, I've tried .Refresh() and various combinations of all of these. I've rebuilt the arraylist which I'm populating from as well. It doesn't refresh.

    The strange thing is when I step through my code it works fine. But when I let it run on its own it doesn't work. Has anybody seen something like this before? If so how do I get around it?

    <oops/>
    This is verision 1.0 of the framework and VS.NET


Comments

  • Registered Users Posts: 2,781 ✭✭✭amen


    not seen that post your code


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    lvUsers.Items.Clear();
    System.Collections.IEnumerator enu = userList.GetEnumerator();
    while(enu.MoveNext())
    {
    	User u = (User)enu.Current;
    	ListViewItem listitem = new ListViewItem(u.StaffName);
    	if(u.IsPartner)
    	{
                     	listitem.SubItems.Add("Partner");
    	                listitem.ImageIndex=1;
    	}
    	else
    	{
                    	listitem.SubItems.Add("Staff");	
                    	listitem.ImageIndex=0;
    	}
    	listitem.Tag = u;
    	this.lvUsers.Items.Add(listitem);
    }
    this.lvUsers.Refresh()
    

    User list is an ArrayList passed to the method as an arguement.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    The code is fine, the problem it turns out is the db. Its Access 2000 (clients choice) and isn't refreshing quick enough when I execute an upate/insert/delete.


  • Registered Users Posts: 437 ✭✭Spunj


    Looks like you are maintaining the data in a collection then refreshing the collection when someone adds/updates/deletes? If so, why not update the collection as you do, then let the collection get refreshed when the user closes/opens the form or clicks off/on to it etc.?

    Wouldn't work too well if others are also accessing the same data at the same time though. Alternatively, if you are using a DataReader to populate the collection you could switch to using a DataTable/DataSet and call its native methods to perform the updates before refreshing your collection from it as it should contain the current data. Not a nice solution performance wise really, but as you are using Access I guess performance isn't a big consideration?


Advertisement