当前位置: 首页>>代码示例>>C#>>正文


C# ListView.Select方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:Garreye,项目名称:meticumedia,代码行数:101,代码来源:OrgItemListHelper.cs


注:本文中的ListView.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。