本文整理汇总了C#中ListView.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Select方法的具体用法?C# ListView.Select怎么用?C# ListView.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListView
的用法示例。
在下文中一共展示了ListView.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayOrgItemInList
//.........这里部分代码省略.........
Color foreColor = Color.Black;
if (resultsCheckSet)
check = orgItem.Check == CheckState.Checked;
else
check = true;
// Set listview item background color based on action
switch (orgItem.Action)
{
case OrgAction.Copy:
case OrgAction.Move:
if (orgItem.QueueStatus != OrgQueueStatus.Paused && orgItem.Progress > 0 && !orgItem.ActionComplete)
backColor = Color.LightYellow;
else
backColor = Color.LightGray;
break;
case OrgAction.Delete:
backColor = Color.LightCoral;
break;
case OrgAction.Queued:
backColor = Color.LightGoldenrodYellow;
break;
case OrgAction.Rename:
backColor = Color.LightGreen;
break;
case OrgAction.AlreadyExists:
backColor = Color.LightYellow;
if (!resultsCheckSet)
check = false;
break;
case OrgAction.Processing:
check = false;
foreColor = Color.Gray;
break;
case OrgAction.TBD:
check = false;
foreColor = Color.LightGray;
break;
default:
// Check only allowed on actions above this
check = false;
break;
}
if (orgItem.QueueStatus == OrgQueueStatus.Failed)
backColor = Color.Red;
else if (orgItem.QueueStatus == OrgQueueStatus.Cancelled)
backColor = Color.Yellow;
else if (orgItem.QueueStatus == OrgQueueStatus.Completed)
backColor = Color.White;
// If update than just grab listview item at current index
if (update)
{
item = lv.Items[i];
if (item.Text != itemText)
item.Text = itemText;
}
// Create new listview item
else
item = lv.Items.Add(itemText);
// Set selections
foreach (int sel in selects)
if (i == sel)
{
item.Selected = true;
item.EnsureVisible();
}
// Apply check to item
if (item.Checked != check)
item.Checked = check;
// Apply background color to item
if (backColor != Color.Transparent && item.BackColor != backColor)
item.BackColor = backColor;
if(item.ForeColor != foreColor)
item.ForeColor = foreColor;
}
// Apply change to text for updates
else if (update)
{
if (item.SubItems[subItemCount].Text != itemText)
item.SubItems[subItemCount].Text = itemText;
}
// Add cell text
else
item.SubItems.Add(itemText);
// Increment subitem count
++subItemCount;
}
}
// Activate listview if new display
if (!update)
lv.Select();
}
}