SIL.FieldWorks.Common.Widgets.FwListBox.ObjectCollection.Clear C# (CSharp) Method

Clear() public method

Clear all items.
Enhance JohnT: add the version that takes an ObjectCollection.
public Clear ( ) : void
return void
			public virtual void Clear()
			{
				CheckDisposed();

				int citems = m_list.Count;
				ClearAllItems();
				var cda = m_owner.DataAccess as IVwCacheDa;
				if (cda == null)
					return; // This can happen, when this is called when 'disposing' is false.
				cda.CacheVecProp(InnerFwListBox.khvoRoot, InnerFwListBox.ktagItems, new int[0], 0);
				if (!m_owner.Updating)
				{
					m_owner.DataAccess.PropChanged(null,
												   (int) PropChangeType.kpctNotifyAll,
												   InnerFwListBox.khvoRoot, InnerFwListBox.ktagItems,
												   0, 0, citems);
				}

				m_owner.SelectedIndex = -1;

				Debug.Assert(m_owner.DataAccess.get_VecSize(InnerFwListBox.khvoRoot, InnerFwListBox.ktagItems) == 0);
			}

Usage Example

コード例 #1
0
ファイル: FwListBoxTests.cs プロジェクト: bbriggs/FieldWorks
		public void Clear_CollectionWithSingleElement_CollectionShouldBeEmpty()
		{
			using (var listBox = new FwListBox())
			{
				using (var collection = new FwListBox.ObjectCollection(listBox))
				{
					ITsString testString = TsStringHelper.MakeTSS("test", m_hvoEnglishWs);
					collection.Add(testString);

					// The Test
					collection.Clear();

					Assert.AreEqual(0, collection.Count);
					Assert.IsFalse(collection.Contains(testString));
				}
			}
		}