/// <summary>
		/// Set the collection of objects that this control will show.
		/// </summary>
		/// <param name="collection"></param>
		/// <remark>This method can safely be called from background threads.</remark>
		public override void SetObjects(IEnumerable collection) {
			if (this.InvokeRequired) {
				this.Invoke((MethodInvoker)delegate { this.SetObjects(collection); });
				return;
			}

			if (this.DataSource == null)
				return;

			this.BeginUpdate();
			try {
				// Give the world a chance to cancel or change the assigned collection
				ItemsChangingEventArgs args = new ItemsChangingEventArgs(null, collection);
				this.OnItemsChanging(args);
				if (args.Canceled)
					return;

				this.DataSource.SetObjects(args.NewObjects);
				this.UpdateVirtualListSize();
				this.Sort();
			} finally {
				this.EndUpdate();
			}
		}
Beispiel #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected virtual void OnItemsChanging(ItemsChangingEventArgs e) {
			if (this.ItemsChanging != null)
				this.ItemsChanging(this, e);
		}