private void List_SelectionChanged(object sender, EventArgs e)
 {
     if (!IgnoreChanges)
     {
         IgnoreChanges = true;
         BoundIds      = ItemsList.GetSelectedIds();
         IgnoreChanges = false;
     }
 }
示例#2
0
        public void PropertiesTest()
        {
            var items = new List <DatabaseObject>()
            {
                new DatabaseObject()
                {
                    Name = "Test1"
                },
                new DatabaseObject()
                {
                    Name = "Test2"
                }
            };

            List <Guid> refIds = null;
            var         dbList = new SelectableDbItemList(items);

            dbList.SelectionChanged += (s, e) =>
            {
                refIds = dbList.GetSelectedIds().ToList();
            };

            var selectionItems = dbList.ToList();

            selectionItems[0].Selected = true;
            selectionItems[1].Selected = true;
            CollectionAssert.IsNotEmpty(refIds);
            Assert.AreEqual("Test1, Test2", dbList.AsString);

            selectionItems[1].Selected = false;
            Assert.AreEqual("Test1", dbList.AsString);
            Assert.AreEqual(1, refIds.Count);

            selectionItems[0].Selected = false;
            CollectionAssert.IsEmpty(refIds);
            Assert.IsEmpty(dbList.AsString);
        }