本文整理汇总了C#中System.Windows.Forms.CheckedListBox.SetSelected方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.SetSelected方法的具体用法?C# CheckedListBox.SetSelected怎么用?C# CheckedListBox.SetSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.SetSelected方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: make_all
private void make_all(int num_of_drives)
{
comparision1st = false;
clear_baseline();
int n = num_of_drives;
int offx, offy, modd;
int d = drives.Count;
offx = 0; offy = 0;
// make them on the run
if (n > 12) { modd = 12; } else { modd = 4; }
for (int i = 1; i <= n; i++)
{
CheckedListBox ata = new CheckedListBox();
Label lata = new Label();
ContextMenu mtt = new ContextMenu();
ContextMenuStrip mt = new ContextMenuStrip();
ata.Name = "ata" + i.ToString();
lata.Name = "lata" + i.ToString();
ata.Size = new Size(pref_w, pref_h);
ata.Font = new Font(ata.Font.FontFamily, 7);
ata.Location = new Point(pata_lx + offx, pata_ly + offy);
lata.Height = pref_h;
lata.Width = pref_w;
lata.Location = new Point(plab_lx + offx, plab_ly + offy + 4);
lata.Text = "Drive" + i.ToString();
for (int j = 0; j < d; j++)
{
ata.Items.Add(drives[j] + " GB", false);
}
ata.CheckOnClick = true;
ata.SetSelected(0, false);
ata.TabIndex = i + 4;
ata.ContextMenuStrip = cms;
this.Controls.Add(ata);
this.Controls.Add(lata);
ata.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(ata_ItemCheck);
ata.MouseUp += new System.Windows.Forms.MouseEventHandler(ata_MouseUp);
offx += pref_w + 10;
if (((i % modd) == 0) & (i != 1))
{ // first drive is 1 then 6th drive is 0
offx = 0;
offy += 110; // that equals 133
}
}
int sw, sh, sw1, sh1;
// get sizes after all controls besides the listbox are there to help size the listbox
sw = this.PreferredSize.Width;
sh = this.PreferredSize.Height;
sw1 = 0;
sh1 = 0;
//ListBox lbr = new ListBox();
RichTextBox lbr = new RichTextBox();
lbr.Name = "lbr";
// lbr.HorizontalScrollbar = true;
lbr.Size = new Size(sw - 25, 280); //used to be 390 then 350 then 280
lbr.Location = new Point(10, sh - 20);
// lbr.ZoomFactor = 0.5;// convert.float(zoomfactor);
lbr.Font = new Font(lbr.Font.FontFamily, fsizereg, lbr.Font.Style);
this.Controls.Add(lbr);
// resize the window
sw1 = this.PreferredSize.Width;
sh1 = this.PreferredSize.Height;
this.Width = sw1 + 10;
this.Height = sh1 + 5;
numberofdrives = n;
}
示例2: CheckAllListboxItems
/// <summary>
/// Check all items in a checked list box
/// </summary>
/// <param name="listBox">The checked list box to modify</param>
private void CheckAllListboxItems(CheckedListBox listBox)
{
if (listBox.Items.Count <= 0)
{
return;
}
for (int listBoxIndex = 0; listBoxIndex < listBox.Items.Count; listBoxIndex++)
{
listBox.SetSelected(listBoxIndex, true);
}
}
示例3: topSelection
public static void topSelection(CheckedListBox tab)
{
if (tab.SelectedIndex.ToString() != "-1")
{
bool etatItem = tab.GetItemChecked(tab.SelectedIndex);
int index;
string valeur;
while (tab.SelectedIndex > 0)
{
valeur = tab.SelectedItem.ToString();
index = tab.SelectedIndex;
tab.Items.RemoveAt(index);
tab.Items.Insert(index - 1, valeur);
tab.SetSelected(index - 1, true);
}
tab.SetItemChecked(tab.SelectedIndex, etatItem);
}
}
示例4: diminueSelection
public static void diminueSelection(CheckedListBox tab)
{
if (tab.SelectedIndex.ToString() != "-1")
{
if (tab.SelectedIndex < tab.Items.Count - 1)
{
bool etatItem = tab.GetItemChecked(tab.SelectedIndex);
string valeur = tab.SelectedItem.ToString();
int index = tab.SelectedIndex;
tab.Items.RemoveAt(index);
tab.Items.Insert(index + 1, valeur);
tab.SetItemChecked(index + 1, etatItem);
tab.SetSelected(index + 1, true);
}
}
}
示例5: FilterListItem
private void FilterListItem(CheckedListBox clb, string filter)
{
if (string.IsNullOrEmpty(filter))
return;
ListItem li;
for (int i = 0; i < clb.Items.Count; i++)
{
li = clb.Items[i] as ListItem;
if (li.Value.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase))
{
clb.SetSelected(i, true);
break;
}
}
}
示例6: limpiarCheckboxList
public static void limpiarCheckboxList(CheckedListBox cbl)
{
foreach (int i in cbl.CheckedIndices)
{
cbl.SetItemCheckState(i, CheckState.Unchecked);
cbl.SetSelected(i,false);
}
}