当前位置: 首页>>代码示例>>C#>>正文


C# CheckedListBox.SetItemChecked方法代码示例

本文整理汇总了C#中System.Windows.Forms.CheckedListBox.SetItemChecked方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.SetItemChecked方法的具体用法?C# CheckedListBox.SetItemChecked怎么用?C# CheckedListBox.SetItemChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.CheckedListBox的用法示例。


在下文中一共展示了CheckedListBox.SetItemChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckListBoxItems

        /// <summary>
        /// Set all items in a CheckedListBox checked/unchecked
        /// </summary>
        /// <param name="_listBox">ListBox to perform operation on</param>
        /// <param name="_select">Selected?</param>
        private void CheckListBoxItems(CheckedListBox _listBox, bool _select) {
            if(_listBox.Items.Count == 0) {
                status.Text = _select ? "Nothing to select." : "Nothing to deselect.";
            }

            for(int i = 0 ; i < _listBox.Items.Count ; i++ ) {
                _listBox.SetItemChecked(i, _select);
            }
        }
开发者ID:tEFFx,项目名称:WikiSense,代码行数:14,代码来源:Form1.cs

示例2: clearItemCheckList

 public static void clearItemCheckList(CheckedListBox check)
 {
     for (int item = 0; item < check.Items.Count; item++)
     {
         check.SetItemChecked(item, false);
     }
 }
开发者ID:MaximilianoFelice,项目名称:gdd-2014,代码行数:7,代码来源:FormHandler.cs

示例3: CheckAll

 /// <summary>
 /// Checks all.
 /// </summary>
 /// <param name="cb">The cb.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void CheckAll(CheckedListBox cb, bool value)
 {
     for (var a = 0; a < cb.Items.Count; a++)
     {
         cb.SetItemChecked(a, value);
     }
 }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:12,代码来源:CheckedListBoxExtras.cs

示例4: ClearCheckedListBox

 public static void ClearCheckedListBox(CheckedListBox ch)
 {
     while (ch.CheckedIndices.Count > 0)
     {
         ch.SetItemChecked(ch.CheckedIndices[0], false);
     }
 }
开发者ID:rafareyes7,项目名称:UnifyWS,代码行数:7,代码来源:HandyClass.cs

示例5: EditValue

        /// <inheritdoc/>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            #region Sanity checks
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (provider == null) throw new ArgumentNullException(nameof(provider));
            #endregion

            var languages = value as LanguageSet;
            if (languages == null) throw new ArgumentNullException(nameof(value));

            var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService == null) return value;

            var listBox = new CheckedListBox {CheckOnClick = true};
            int i = 0;
            foreach (var language in languages)
            {
                listBox.Items.Add(language);
                listBox.SetItemChecked(i++, true);
            }
            foreach (var language in Languages.AllKnown.Except(languages))
                listBox.Items.Add(language);

            editorService.DropDownControl(listBox);

            return new LanguageSet(listBox.CheckedItems.Cast<CultureInfo>());
        }
开发者ID:nano-byte,项目名称:common,代码行数:28,代码来源:LanguageSetEditor.cs

示例6: CheckItem

 /// <summary>
 /// Checks the item.
 /// </summary>
 /// <param name="cb">The cb.</param>
 /// <param name="item">The item.</param>
 public static void CheckItem(CheckedListBox cb, string item)
 {
     for (var a = 0; a < cb.Items.Count; a++)
     {
         if (cb.Items[a].Equals(item))
         {
             cb.SetItemChecked(a, true);
         }
     }
 }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:15,代码来源:CheckedListBoxExtras.cs

示例7: InitExcludes

        /// <summary>
        /// Sets up check list boxs 
        /// </summary>
        /// <param name="listbox"></param>
        /// <param name="defaultExcludeTypes"></param>
        /// <param name="userExcludeTypes"></param>
        private void InitExcludes(CheckedListBox listbox, List<Type> defaultExcludeTypes, List<Type> userExcludeTypes)
        {
            ((ListBox)listbox).DataSource = defaultExcludeTypes;
            ((ListBox)listbox).DisplayMember = "Name";

            for (int i = 0; i < listbox.Items.Count; i++)
            {
                Type typeObj = (Type)listbox.Items[i];
                if (userExcludeTypes.Contains(typeObj))
                    listbox.SetItemChecked(i, true);
            }
        }
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:18,代码来源:ClassFilter.cs

示例8: Draw

        public static void Draw( CheckedListBox list )
        {
            list.BeginUpdate();
            list.Items.Clear();

            for (int i=0;i<m_Filters.Count;i++)
            {
                Filter f = (Filter)m_Filters[i];
                list.Items.Add( f );
                list.SetItemChecked( i, f.Enabled );
            }
            list.EndUpdate();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:13,代码来源:Filter.cs

示例9: SetCheck

 public static void SetCheck(CheckedListBox cblItems, string valueList)
 {
     string[] strtemp = valueList.Split(',');
     foreach (string str in strtemp)
     {
         for (int i = 0; i < cblItems.Items.Count; i++)
         {
             if (cblItems.GetItemText(cblItems.Items[i]) == str)
             {
                 cblItems.SetItemChecked(i, true);
             }
         }
     }
 }
开发者ID:Andy-Yin,项目名称:MY_OA_RM,代码行数:14,代码来源:CheckBoxListUtil.cs

示例10: SetCheckboxItemChecked

 public void SetCheckboxItemChecked(CheckedListBox control, int index, bool val)
 {
     if (control.InvokeRequired)
       {
     SetCheckboxItemCheckedCallback d = SetCheckboxItemChecked;
     try
     {
       Invoke(d, new object[] { control, index, val });
     }
     catch (Exception) { }
       }
       else
       {
     control.SetItemChecked(index, val);
       }
 }
开发者ID:bramp,项目名称:libcec,代码行数:16,代码来源:AsyncForm.cs

示例11: CheckToggleAll

 private void CheckToggleAll(CheckedListBox chibby,CheckBox master)
 {
     if (master.Checked)
     {
         for (int i = 0; i < chibby.Items.Count; i++)
         {
             chibby.SetItemChecked(i, true);
         }
     }
     else
     {
         for (int i = 0; i < chibby.Items.Count; i++)
         {
             chibby.SetItemChecked(i, false);
         }
     }
 }
开发者ID:quiltedvino,项目名称:TOBS,代码行数:17,代码来源:frmSuggestions.cs

示例12: ItemCheckTest

		public void ItemCheckTest ()
		{
			Form myform = new Form ();
			myform.ShowInTaskbar = false;
			CheckedListBox mychklstbox = new CheckedListBox ();
			mychklstbox.Items.Add ("test1"); 
			mychklstbox.Items.Add ("test2"); 
			//Test ItemCheck Event
			mychklstbox.ItemCheck += new ItemCheckEventHandler (ItemCheck_EventHandler);		
			mychklstbox.Items.Add ("test1",CheckState.Checked);
			myform.Controls.Add (mychklstbox);
			myform.Show ();
			Assert.AreEqual (true, eventhandled, "#A1");
			eventhandled = false;
			mychklstbox.SetItemChecked (1,true);
			Assert.AreEqual (true, eventhandled, "#A2");
			myform.Dispose ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:CheckedListBoxEventTest.cs

示例13: FillCheckedListBoxFromString

        private void FillCheckedListBoxFromString(object obj, CheckedListBox listBox)
        {
            string value = obj.ToString();
            if (value == NoFlags)
                return;

            char[] delimiters = new[] { '|', ';', ',', ':' };
            string[] flags = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
            foreach (string flag in flags)
            {
                for (int i = 0; i < m_names.Length; i++)
                {
                    if (flag == m_names[i])
                    {
                        listBox.SetItemChecked(i, true);
                        break;
                    }
                }
            }
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:20,代码来源:FlagsUITypeEditor.cs

示例14: InitializeResponseControl

        private Control InitializeResponseControl(List<StandardValidTerm> codeList, List<StandardValidTerm> initialSelection, bool addFirstDefault)
        {
            var ptX = _lblEntity.Location.X + 3;
            var ptY = _lblEntity.Location.Y + _lblEntity.Height;
            if (_staticDisplayItems != null)
            {
                var staticLines = String.Empty;
                foreach (var staticDisplayItem in _staticDisplayItems)
                    staticLines += staticDisplayItem + Environment.NewLine;

                var label = new Label
                {
                    Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                    Margin = new Padding(4),
                    Location = new System.Drawing.Point(ptX, ptY),
                    Name = "staticDisplayItemLabel"
                };
                label.AutoSize = true;
                label.Text = staticLines;

                return label;
            }

            if (_maxNumberOfAnswers > 1)
            {
                var chklistEntity = new CheckedListBox();
                chklistEntity.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                chklistEntity.FormattingEnabled = true;
                chklistEntity.Margin = new Padding(4);
                chklistEntity.Location = new System.Drawing.Point(ptX, ptY);
                chklistEntity.IntegralHeight = false;
                chklistEntity.Name = "chklistEntity";
                var ctrlHeight = (codeList == null ? 1 : Math.Max(1, codeList.Count)) * (chklistEntity.ItemHeight + 2) + chklistEntity.ItemHeight / 2;
                chklistEntity.Size = new System.Drawing.Size(Width - ptX, ctrlHeight);
                chklistEntity.TabIndex = 1;
                chklistEntity.CheckOnClick = true;

                foreach (var validTerm in codeList)
                {
                    var idx = chklistEntity.Items.Add(new ValidTermListItem(validTerm));
                    var sequence = validTerm;
                    if (initialSelection != null && CollectionUtils.Contains(initialSelection, cs => cs.Equals(sequence)))
                        chklistEntity.SetItemChecked(idx, true);
                }
                chklistEntity.ItemCheck += OnItemCheck;

                return chklistEntity;
            }

            var ddlEntity = new ComboBox();
            ddlEntity.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            ddlEntity.DropDownStyle = ComboBoxStyle.DropDownList;
            ddlEntity.FormattingEnabled = true;
            ddlEntity.Margin = new Padding(4);
            ddlEntity.Location = new System.Drawing.Point(ptX, ptY);
            ddlEntity.Name = "ddlEntity";
            ddlEntity.Size = new System.Drawing.Size(Width - ptX, ddlEntity.Height);
            ddlEntity.TabIndex = 1;

            if (addFirstDefault)
                ddlEntity.Items.Add(new ValidTermListItem(null));
            foreach (var validTerm in codeList)
            {
                var idx = ddlEntity.Items.Add(new ValidTermListItem(validTerm));
                var term = validTerm;
                if (initialSelection != null && ddlEntity.SelectedIndex == -1 && CollectionUtils.Contains(initialSelection, cs => cs.Equals(term)))
                    ddlEntity.SelectedIndex = idx;
            }

            if (ddlEntity.SelectedIndex == -1 && ddlEntity.Items.Count > 0)
                ddlEntity.SelectedIndex = 0;

            ddlEntity.DropDown += OnDropDown;
            ddlEntity.SelectedIndexChanged += OnSelectedIndexChanged;

            return ddlEntity;
        }
开发者ID:vikasvm,项目名称:annotation-and-image-markup,代码行数:77,代码来源:SimpleQuestionControl.cs

示例15: DeleteSelectedTasks

        /// <summary>
        /// Deletes the selected tasks.
        /// </summary>
        /// <param name="viewAbleList">The view able list.</param>
        /// <param name="filterList">The filter list.</param>
        /// <param name="tags">The tags.</param>
        public void DeleteSelectedTasks(ListView viewAbleList, CheckedListBox filterList, string[] tags)
        {
            List<string> preservedFilterChecks = GetFiltersSelected(filterList);
            filterList.Items.Clear();
            filters.Clear();
            SetDefaultFilters(filterList, tags);

            int i = 0;
            while (i < taskList.Count)
            {
                int j = 0;
                while (j < viewAbleList.SelectedItems.Count)
                {
                    if (taskList[i].date.ToShortDateString() == viewAbleList.SelectedItems[j].SubItems[0].Text
                         && taskList[i].tag == viewAbleList.SelectedItems[j].SubItems[1].Text
                         && taskList[i].task == viewAbleList.SelectedItems[j].SubItems[2].Text)
                    {
                        taskList.RemoveAt(i);
                        i -= 1;
                        break;
                    }
                    ++j;
                }
                ++i;
            }
            UpdateTaskList(viewAbleList, filterList, false);
            i = 0;
            while (i < filterList.Items.Count)
            {
                if (preservedFilterChecks.Contains(filterList.Items[i].ToString()))
                {
                    filterList.SetItemChecked(i, true);
                }
                ++i;
            }
            UpdateTaskList(viewAbleList, filterList);
            this.Save();
        }
开发者ID:ajrod,项目名称:Task-Manager,代码行数:44,代码来源:TaskDataBase.cs


注:本文中的System.Windows.Forms.CheckedListBox.SetItemChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。