本文整理汇总了C#中System.Windows.Forms.CheckedListBox.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.GetText方法的具体用法?C# CheckedListBox.GetText怎么用?C# CheckedListBox.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
}
}
}
示例2: InsertAt
public static void InsertAt(this CheckedListBox chList, int index, string item, bool check)
{
CheckedListBox aux = new CheckedListBox();
bool itemAdded = false;
for (int i = 0; i < chList.Items.Count; i++)
{
if (i == index && !itemAdded)
{
aux.Items.Add(item, check);
itemAdded = true;
i--;
}
else
{
aux.Items.Add(chList.GetText(i), chList.GetItemChecked(i));
}
}
if (!itemAdded)
{
chList.Items.Add(item, check);
}
else
{
chList.Items.Clear();
for (int i = 0; i < aux.Items.Count; i++)
chList.Items.Add(aux.GetText(i), aux.GetItemChecked(i));
}
}