本文整理汇总了C#中System.Windows.Forms.CheckedListBox.GetItemText方法的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox.GetItemText方法的具体用法?C# CheckedListBox.GetItemText怎么用?C# CheckedListBox.GetItemText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckedListBox
的用法示例。
在下文中一共展示了CheckedListBox.GetItemText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(',');
}
示例2: 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);
}
}
}
}
示例3: DrawCheckedListBoxItem
public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
{
Color back_color, fore_color;
Rectangle item_rect = e.Bounds;
ButtonState state;
/* Draw checkbox */
if ((e.State & DrawItemState.Checked) == DrawItemState.Checked) {
state = ButtonState.Checked;
if ((e.State & DrawItemState.Inactive) == DrawItemState.Inactive)
state |= ButtonState.Inactive;
} else
state = ButtonState.Normal;
if (ctrl.ThreeDCheckBoxes == false)
state |= ButtonState.Flat;
Rectangle checkbox_rect = new Rectangle (2, (item_rect.Height - 11) / 2, 13, 13);
ControlPaint.DrawCheckBox (e.Graphics,
item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
checkbox_rect.Width, checkbox_rect.Height,
state);
item_rect.X += checkbox_rect.Right;
item_rect.Width -= checkbox_rect.Right;
/* Draw text*/
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
back_color = ColorHighlight;
fore_color = ColorHighlightText;
}
else {
back_color = e.BackColor;
fore_color = e.ForeColor;
}
e.Graphics.FillRectangle (ResPool.GetSolidBrush
(back_color), item_rect);
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
ResPool.GetSolidBrush (fore_color),
item_rect, ctrl.StringFormat);
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
CPDrawFocusRectangle (e.Graphics, item_rect,
fore_color, back_color);
}
}