示例#1
0
        //因为checkedListBox1仅有选中前发生事件(ItemCheck)没有选中后发生事件,所以要针对当前选中的Item进行反向处理
        private List <SortInfo> GetLstSortInfo(CheckedListBox checkedListBox1, int curIndex)
        {
            List <SortInfo> lstSortCategory = new List <SortInfo>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                CheckState cs = checkedListBox1.GetItemCheckState(i);
                //如果是
                if (i == curIndex)
                {
                    cs = cs == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked;
                }

                if (cs != CheckState.Checked)
                {
                    continue;
                }
                CheckedListBoxItem clbi = checkedListBox1.Items[i] as CheckedListBoxItem;
                if (clbi == null)
                {
                    continue;
                }
                SortInfo sort = new SortInfo();
                sort.Type      = clbi.Type;
                sort.Ascending = true;

                lstSortCategory.Add(sort);
            }

            return(lstSortCategory);
        }
示例#2
0
 private void InitCheckedListBox(CheckedListBox checkedListBox1)
 {
     checkedListBox1.Items.Clear();
     foreach (KeyValuePair <SortType, string> item in EnumDictionary <SortType> .Instance.Dictionary)
     {
         CheckedListBoxItem clbi = new CheckedListBoxItem();
         clbi.Text = item.Value;
         clbi.Type = item.Key;
         checkedListBox1.Items.Add(clbi, false);
     }
 }
示例#3
0
        private List <SortInfo> GetLstSortInfo(CheckedListBox checkedListBox1)
        {
            List <SortInfo> lstSortCategory = new List <SortInfo>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i) == false)
                {
                    continue;
                }
                CheckedListBoxItem clbi = checkedListBox1.Items[i] as CheckedListBoxItem;
                SortInfo           sort = new SortInfo();
                sort.Type      = clbi.Type;
                sort.Ascending = true;

                lstSortCategory.Add(sort);
            }

            return(lstSortCategory);
        }