本文整理汇总了C#中System.Windows.Forms.CheckedListBox.SetItemCheckState方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.SetItemCheckState方法的具体用法?C# CheckedListBox.SetItemCheckState怎么用?C# CheckedListBox.SetItemCheckState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.SetItemCheckState方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mostrarServicios
public void mostrarServicios(ref CheckedListBox miCombo, string t_primera,string t_eco,string t_turista)
{
miCombo.Items.Add("Primera Clase");
miCombo.Items.Add("Ejecutivo");
miCombo.Items.Add("Turista");
if (t_primera == "Sí") { miCombo.SetItemCheckState(0, CheckState.Checked); }
if (t_eco == "Sí") { miCombo.SetItemCheckState(1, CheckState.Checked); }
if (t_turista == "Sí") { miCombo.SetItemCheckState(2, CheckState.Checked); }
}
示例2: SetCheckState
private static void SetCheckState(CheckedListBox clb, string value, CheckState state)
{
int index = 0;
foreach(object item in clb.Items)
{
if(item.ToString() == value)
{
clb.SetItemCheckState(index, state);
return;
}
index++;
}
}
示例3: ClearAllCheckState
private static void ClearAllCheckState(CheckedListBox clb)
{
for(int i = 0; i < clb.Items.Count; i++)
{
clb.SetItemCheckState(i, CheckState.Unchecked);
}
}
示例4: SetItemCheckStateTest
public void SetItemCheckStateTest ()
{
Form myform = new Form ();
myform.ShowInTaskbar = false;
myform.Visible = true;
CheckedListBox mychklistbox = new CheckedListBox ();
mychklistbox.Items.Add ("test1");
mychklistbox.Items.Add ("test2");
mychklistbox.Items.Add ("test3");
mychklistbox.Visible = true;
myform.Controls.Add (mychklistbox);
mychklistbox.SetItemCheckState (0,CheckState.Checked);
mychklistbox.SetItemCheckState (1,CheckState.Indeterminate);
mychklistbox.SetItemCheckState (2,CheckState.Unchecked);
Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#19");
Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#20");
Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#21");
myform.Dispose ();
}
示例5: CheckAllEsce
/// <summary>
/// 全部取选中方法
/// </summary>
/// <param name="chckList">控件对象</param>
public void CheckAllEsce(CheckedListBox ckl)
{
for (int i = 0; i < ckl.Items.Count; i++)//遍历控件中的项并赋值
{ ckl.SetItemCheckState(i, CheckState.Unchecked); }
}
示例6: btnMoveUp_Click
private void btnMoveUp_Click(object sender, System.EventArgs e)
{
int index = chkLstFields.SelectedIndices[0];
if(index!=0)
{
ArrayList list = new ArrayList();
CheckedListBox cb = new CheckedListBox();
cb.Items.AddRange(chkLstFields.Items);
for(int i=0; i<chkLstFields.CheckedItems.Count; i++)
{
cb.SetItemCheckState(cb.Items.IndexOf(chkLstFields.CheckedItems[i]),CheckState.Checked);
}
list.AddRange(chkLstFields.Items);
ArrayList newlist = new ArrayList(list);
newlist[index] = list[index-1];
newlist[index-1] = list[index];
chkLstFields.Items.Clear();
chkLstFields.Items.AddRange((string[])newlist.ToArray(typeof(string)));
for(int i=0; i<cb.CheckedItems.Count; i++)
{
chkLstFields.SetItemCheckState(chkLstFields.Items.IndexOf(cb.CheckedItems[i]),CheckState.Checked);
}
chkLstFields.SelectedItem = chkLstFields.Items[index-1];
}
}
示例7: copyPanelItems
private void copyPanelItems(Tuple<string, Func<int, int, int>, int, int, int, int, int>[] panelSrc,
CheckedListBox listSrc,
Tuple<string, Func<int, int, int>, int, int, int, int, int>[] panelDest,
CheckedListBox listDest)
{
for (int a = 0; a < panelSrc.Length; a++)
{
if (panelSrc[a] != null)
{
// copy panel item
panelDest[a] = new Tuple<string,Func<int,int,int>,int,int,int,int,int>(
panelSrc[a].Item1, panelSrc[a].Item2, panelSrc[a].Item3, panelSrc[a].Item4, panelSrc[a].Item5, panelSrc[a].Item6, panelSrc[a].Item7);
// copy checked item list
listDest.SetItemCheckState(a, listSrc.GetItemCheckState(a));
}
else
{
panelDest[a] = null;
}
}
}
示例8: showKlamotteStimmungCLBMask
//CheckedListBox für die Zuordnung von Stimmungen und Klamotten
public static DialogResult showKlamotteStimmungCLBMask(ref string[] stimmungen_set, string[] stimmungen_all, string klamotte_bezeichnung)
{
// Form
System.Drawing.Size size = new System.Drawing.Size(300, 150);
Form stimmungen_clb = new Form();
stimmungen_clb.FormBorderStyle = FormBorderStyle.Fixed3D;
stimmungen_clb.ClientSize = size;
stimmungen_clb.Text = "w2w - Stimmungen für " + klamotte_bezeichnung + " zuordnen:";
// Checklistboxen
CheckedListBox clb = new CheckedListBox();
clb.Size = new System.Drawing.Size(size.Width - 10, 100);
clb.Location = new System.Drawing.Point(5, 5);
clb.Items.AddRange(stimmungen_all);
clb.CheckOnClick = true;
stimmungen_clb.Controls.Add(clb);
// Buttons
Button cancelButton = new Button();
cancelButton.DialogResult = DialogResult.Cancel;
cancelButton.Name = "cancelButton";
cancelButton.Size = new System.Drawing.Size(70, 30);
cancelButton.Text = "&Abbrechen";
cancelButton.Location = new System.Drawing.Point(size.Width - 80, clb.Location.Y + clb.Size.Height + 10);
stimmungen_clb.Controls.Add(cancelButton);
Button deleteButton = new Button();
deleteButton.DialogResult = DialogResult.OK;
deleteButton.Name = "okButton";
deleteButton.Size = new System.Drawing.Size(70, 30);
deleteButton.Text = "&OK";
deleteButton.Location = new System.Drawing.Point(size.Width - 80 - 80, clb.Location.Y + clb.Size.Height + 10);
stimmungen_clb.Controls.Add(deleteButton);
// Zuweisen der Buttons zu Ereignissen
stimmungen_clb.AcceptButton = deleteButton;
stimmungen_clb.CancelButton = cancelButton;
stimmungen_clb.StartPosition = FormStartPosition.CenterParent;
for (int i = 0; i < clb.Items.Count; i++)
{
if (stimmungen_set.Contains(clb.Items[i].ToString()))
{
clb.SetItemCheckState(i, CheckState.Checked);
}
}
// Anzeigen des Dialogs
DialogResult result = stimmungen_clb.ShowDialog();
// Überschreiben der Referenz mit Inhalt der Eingabebox
Array.Clear(stimmungen_set, 0, stimmungen_set.Length);
Array.Resize(ref stimmungen_set, clb.CheckedItems.Count);
clb.CheckedItems.CopyTo(stimmungen_set, 0);
// Zurückgeben des Dialog Ergebnisses
return result;
}
示例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: SetAllCheckedListItems
private static void SetAllCheckedListItems(CheckedListBox listBox, CheckState state)
{
for (int index = 0; index < listBox.Items.Count; index++)
listBox.SetItemCheckState(index, state);
}
示例11: limpiarCheckboxList
public static void limpiarCheckboxList(CheckedListBox cbl)
{
foreach (int i in cbl.CheckedIndices)
{
cbl.SetItemCheckState(i, CheckState.Unchecked);
cbl.SetSelected(i,false);
}
}