On Oct 3, 2006, at 2:26 AM, Carlos M wrote:

One of the problems on a ListBox when selecting all rows with the usual loop is that the ListBox Change event will fire for each row that is being selected. So, if you have 2,000 rows in a ListBox, the Change event fires 2,000 times! And if you have (like I had) code on the Change event to check for selected rows and do some stuff, then you can imagine the problems it caused!

You cannot stop the Change event from firing, but what I usually do is add a condition to run the code within the Change event. Something like:

// ModificationLock is a property of Window or Listbox subclass, and having it
  // return like this short-circuits this event

  If ModificationLock Then Return

  // change code goes here

There are lots of reasons to have a ModificationLock property, not just SelectAll. For example, if you have text in your EditField.TextChange event, that event will also fire every time you change the code in text. If you want to limit the code within the event for just user modifications to the text, you can use a ModificationLock. You would use it like:

  ModificationLock = True
  Me.Text = "something cool here"
  ModificationLock = False

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to