本文整理汇总了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);
}
}
示例2: clearItemCheckList
public static void clearItemCheckList(CheckedListBox check)
{
for (int item = 0; item < check.Items.Count; item++)
{
check.SetItemChecked(item, false);
}
}
示例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);
}
}
示例4: ClearCheckedListBox
public static void ClearCheckedListBox(CheckedListBox ch)
{
while (ch.CheckedIndices.Count > 0)
{
ch.SetItemChecked(ch.CheckedIndices[0], false);
}
}
示例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>());
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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 ();
}
示例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;
}
}
}
}
示例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;
}
示例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();
}