Exemplo n.º 1
0
        public void newItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            ListViewItemViewModel item = ((ListViewItemViewModel)sender);

            if (item.Selected || item.Focused)
            {
                int index = Items.IndexOf(item);
                if (index > -1)
                {
                    SelectedIndices.Add(index);
                }
            }
            if (item.Checked)
            {
                int index = Items.IndexOf(item);
                if (index > -1)
                {
                    CheckedIndices.Add(index);
                }
            }
        }
 private void OnCaseChecked(object sender, ItemCheckEventArgs e)
 {
     // build list of checked items in chklbCases
     CheckedIndices.Clear();
     foreach (int index in chklbCases.CheckedIndices)
     {
         CheckedIndices.Add(index);
     }
     if (null != e)
     {
         if (e.NewValue == CheckState.Checked)
         {
             CheckedIndices.Add(e.Index);
         }
         else if (e.NewValue == CheckState.Unchecked)
         {
             CheckedIndices.Remove(e.Index);
         }
     }
     UpdateStatus(string.Empty);
     timer.Stop();
     timer.Start();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a new element to the combo
        /// </summary>
        /// <param name="item">item to add</param>
        /// <param name="index">position to adding</param>
        public int AddItem(object item, int index = -1)
        {
            var newItem = CreateItem(item);

            if (index == -1 || index == ListViewItemViewModels.Count)
            {
                ListViewItemViewModels.Add(newItem);
                SortElements();
                ListViewItemViewModels_CollectionChanged();
                if (newItem.Selected)
                {
                    SelectedIndices.Add(newItem.Index);
                }
                if (newItem.Checked)
                {
                    CheckedIndices.Add(newItem.Index);
                }

                return(newItem.Index);
            }
            ListViewItemViewModels.Insert(index, newItem);
            SortElements();
            return(index);
        }