本文整理汇总了C#中System.Windows.Forms.CheckedListBox.GetItemChecked方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.GetItemChecked方法的具体用法?C# CheckedListBox.GetItemChecked怎么用?C# CheckedListBox.GetItemChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.GetItemChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditValue
/// <summary>
/// Edits a value based on some user input which is collected from a character control.
/// </summary>
/// <param name="context"></param>
/// <param name="provider"></param>
/// <param name="value"></param>
/// <returns></returns>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
_dialogProvider = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
List<int> layerList = new List<int>();
LayoutLegend legend = context.Instance as LayoutLegend;
LayoutMap map = null;
if (legend != null)
map = legend.Map;
if (map == null)
return layerList;
CheckedListBox lb = new CheckedListBox();
List<int> originalList = value as List<int>;
if (originalList != null)
{
for (int i = map.MapControl.Layers.Count - 1; i >= 0 ; i--)
lb.Items.Add(map.MapControl.Layers[i].LegendText, originalList.Contains(i));
}
_dialogProvider.DropDownControl(lb);
for (int i = 0; i < lb.Items.Count; i ++)
{
if (lb.GetItemChecked(i))
layerList.Add(lb.Items.Count - 1 -i);
}
return layerList;
}
示例2: GetMaterials
private void GetMaterials(ref EDPlanet obj, CheckedListBox box)
{
for (int i = 0; i < box.Items.Count; i++)
{
string item = (string)box.Items[i];
MaterialEnum mat = obj.MaterialFromString(item);
obj.materials[mat] = box.GetItemChecked(i);
}
}
示例3: checkBoxListEmpty
public static Boolean checkBoxListEmpty(CheckedListBox cbl)
{
for (int i = 0; i < cbl.Items.Count; i++)
{
if (cbl.GetItemChecked(i) == true) return false;
}
return true;
}
示例4: CheckedListBoxItemsAreAllUnchecked
private bool CheckedListBoxItemsAreAllUnchecked(CheckedListBox listbox)
{
for (int i = 0; i < listbox.Items.Count; i++)
{
if (listbox.GetItemChecked(i))
return false;
}
return true;
}
示例5: UpdateActiveSitesInSetup
public void UpdateActiveSitesInSetup(CheckedListBox sitesList)
{
ActiveSites.Clear();
for (var index = 0; index < sitesList.Items.Count; index++)
{
var active = sitesList.GetItemChecked(index);
if (active)
{
ActiveSites.Add((string) (sitesList.Items[index]));
}
}
}
示例6: GetCheckedItems
public static string GetCheckedItems(CheckedListBox cblItems)
{
string resultList = "";
for (int i = 0; i < cblItems.CheckedItems.Count; i++)
{
if (cblItems.GetItemChecked(i))
{
resultList += string.Format("{0},", cblItems.GetItemText(cblItems.Items[i]));
}
}
return resultList.Trim(',');
}
示例7: get_CheckListBox
public static String get_CheckListBox(CheckedListBox chk)
{
string tmp = "";
for (int r = 0; r < chk.Items.Count; r++)
{
if (chk.GetItemChecked(r))
{
string ID = ((ListItem)chk.Items[r]).ID;
tmp += " " + ID;
}
}
return tmp.Trim();
}
示例8: getStrings
private void getStrings(CheckedListBox listBox, ref StringList strings)
{
int i;
for (i = 0; i < listBox.Items.Count; i++)
{
if (listBox.GetItemChecked(i))
{
String itemText = listBox.Items[i].ToString();
strings.Add(itemText);
}
}
}
示例9: DualChListMouseEvent
/// <summary>
/// Left mouse click: check/uncheck the item.
/// Middle mouse click: remove item.
/// Right mouse click: send item from chList1 to chList2.
/// </summary>
/// <param name="chList1"> The handled checkedListBox. </param>
/// <param name="chList2"> The dual checkedListBox. </param>
/// <param name="e"> The mouse click event. </param>
public static void DualChListMouseEvent(CheckedListBox chList1, CheckedListBox chList2, MouseEventArgs e, Point mousePosition, bool useDual = true)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
for (int i = 0; i < chList1.Items.Count; i++)
{
if (i != 0 || useDual)
{
if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition)))
{
chList2.AddOrderedFromBottom(chList1.GetText(i), chList1.GetItemChecked(i));
chList1.Items.RemoveAt(i);
}
}
}
}
else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
{
for (int i = 0; i < chList1.Items.Count; i++)
{
if (i != 0 || useDual)
{
if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition)))
{
chList1.Items.RemoveAt(i);
}
}
}
}
else if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
for (int i = 0; i < chList1.Items.Count; i++)
{
if (chList1.GetItemRectangle(i).Contains(chList1.PointToClient(mousePosition)))
{
switch (chList1.GetItemCheckState(i))
{
case CheckState.Checked:
chList1.SetItemCheckState(i, CheckState.Unchecked);
break;
case CheckState.Indeterminate:
case CheckState.Unchecked:
chList1.SetItemCheckState(i, CheckState.Checked);
break;
}
}
}
}
}
示例10: SetExcludes
/// <summary>
/// Save the excludes to the UserFilters
/// </summary>
/// <param name="listbox"></param>
/// <param name="userExcludeTypes"></param>
private void SetExcludes(CheckedListBox listbox, List<Type> userExcludeTypes)
{
for (int i = 0; i < listbox.Items.Count; i++)
{
Type typeObj = (Type)listbox.Items[i];
if (listbox.GetItemChecked(i))
{
if (!userExcludeTypes.Contains(typeObj))
userExcludeTypes.Add(typeObj);
}
else
userExcludeTypes.Remove(typeObj);
}
}
示例11: CheckedListValidator
public static bool CheckedListValidator(CheckedListBox ch)
{
var hasChecked = false;
for (int i = 0; i < ch.Items.Count; i++)
{
if (ch.GetItemChecked(i))
{
hasChecked = true;
break;
}
}
if (hasChecked==false)
{
return false;
}
return true;
}
示例12: selectItemIndex
public static int selectItemIndex(CheckedListBox clb)
{
for (int i = 0; i < clb.Items.Count; i++)
{
if (clb.GetItemChecked(i)) return i;
}
return 0;
}
示例13: listDown
private void listDown(CheckedListBox listBox)
{
if (listBox.SelectedIndex == -1 || listBox.SelectedIndex == listBox.Items.Count - 1)
return;
object selected;
object next;
object temp;
bool selectedChecked;
bool nextChecked;
bool tempChecked;
selected = listBox.Items[listBox.SelectedIndex];
selectedChecked = listBox.GetItemChecked(listBox.SelectedIndex);
next = listBox.Items[listBox.SelectedIndex + 1];
nextChecked = listBox.GetItemChecked(listBox.SelectedIndex + 1);
temp = selected;
tempChecked = selectedChecked;
selected = next;
selectedChecked = nextChecked;
next = temp;
nextChecked = tempChecked;
listBox.Items[listBox.SelectedIndex] = selected;
listBox.SetItemChecked(listBox.SelectedIndex, selectedChecked);
listBox.Items[listBox.SelectedIndex + 1] = next;
listBox.SetItemChecked(listBox.SelectedIndex + 1, nextChecked);
listBox.SelectedIndex++;
}
示例14: ApplyTags
public static void ApplyTags(string key, CheckedListBox box, ItemCheckEventArgs e)
{
if (Resetting > 0) return;
object[] vals = new object[box.CheckedItems.Count + (e.NewValue == CheckState.Checked ? 1 : -1)];
int d = 0;
for (int c = 0; c < box.Items.Count; c++)
{
if (box.GetItemChecked(c))
{
if (c != e.Index || e.NewValue != CheckState.Unchecked)
{
vals[d] = box.Items[c].ToString();
d++;
}
}
}
if (e.NewValue == CheckState.Checked)
vals[d] = box.Items[e.Index].ToString();
if (key.Equals("material") && vals.Length == 1)
ApplyValue(key, vals[0], ((JsonFormTag)box.Tag).mandatory);
else
ApplyValue(key, vals, ((JsonFormTag)box.Tag).mandatory);
}
示例15: GetItemCheckedExceptionTest
public void GetItemCheckedExceptionTest ()
{
CheckedListBox mychklistbox = new CheckedListBox ();
mychklistbox.Items.Add ("test1",true);
Assert.AreEqual (true, mychklistbox.GetItemChecked (1), "#13");
}