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


C# ListView.Invalidate方法代码示例

本文整理汇总了C#中System.Windows.Forms.ListView.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Invalidate方法的具体用法?C# ListView.Invalidate怎么用?C# ListView.Invalidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ListView的用法示例。


在下文中一共展示了ListView.Invalidate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckListViewLines

        /// <summary>
        /// Checks the list view lines.
        /// </summary>
        /// <param name="listView">The list view.</param>
        /// <remarks>Documented by Dev02, 2007-11-30</remarks>
        private static void CheckListViewLines(ListView listView)
        {
            StripListViewLines(listView);

            listView.BeginUpdate();

            //check all lines for missing tags
            foreach (ListViewItem lvi in listView.Items)
            {
                if (lvi.Tag == null || !(lvi.Tag is WordType))
                    lvi.Tag = WordType.Word;
            }

            //check for lines to add
            if (listView.Items.Count == 0 || (listView.Items.Count > 0 && !string.IsNullOrEmpty(listView.Items[listView.Items.Count - 1].Text)))
                listView.Items.Add(string.Empty);

            //highlight distractors
            foreach (ListViewItem item in listView.Items)
            {
                if (item.Tag is WordType && ((WordType)item.Tag == WordType.Distractor))
                {
                    item.BackColor = Properties.Settings.Default.distractorColor;
                    item.ToolTipText = Properties.Resources.CARDEDIT_TOOLTIP_DISTRACTOR;
                }
                else
                    item.BackColor = Color.Transparent;
            }

            //highlight each second line
            int line = 0;
            foreach (ListViewItem lvi in listView.Items)
            {
                if (lvi.BackColor != Properties.Settings.Default.distractorColor)
                {
                    if (line % 2 > 0)
                        lvi.BackColor = Properties.Settings.Default.secondLineColor;
                    else
                        lvi.BackColor = listView.BackColor;
                }
                line++;
            }

            listView.EndUpdate();
            listView.Invalidate();
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:51,代码来源:CardEdit.cs

示例2: StripListViewLines

        /// <summary>
        /// Removes all empty list view lines.
        /// </summary>
        /// <param name="listView">The list view.</param>
        /// <remarks>Documented by Dev02, 2008-01-28</remarks>
        private static void StripListViewLines(ListView listView)
        {
            listView.BeginUpdate();

            //check for lines to delete
            List<ListViewItem> lvisToDelete = new List<ListViewItem>();
            foreach (ListViewItem lvi in listView.Items)
                if (lvi == null || string.IsNullOrEmpty(lvi.Text))
                    lvisToDelete.Add(lvi);
            foreach (ListViewItem lvi in lvisToDelete)
                listView.Items.Remove(lvi);

            listView.EndUpdate();
            listView.Invalidate();
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:20,代码来源:CardEdit.cs

示例3: SyncListView

 private void SyncListView(IEnumerable<SkeletonItem> items, ListView listView, Action<DisplayItem, SkeletonItem> cb)
 {
     var ch = items.ToArray();
       var missing = ch.Length - listView.Items.Count;
       listView.BeginUpdate();
       if (missing < 0) {
     missing = -missing;
     while (missing-- > 0) {
       listView.Items.RemoveAt(listView.Items.Count - 1);
     }
       } else {
     while (missing-- > 0) {
       listView.Items.Add(new DisplayItem());
     }
       }
       for (int i = 0; i < ch.Length; ++i) {
     var di = (DisplayItem)listView.Items[i];
     cb(di, ch[i]);
     di.Set(ch[i], CurrentState, PreviousState);
       }
       listView.EndUpdate();
       listView.Invalidate();
 }
开发者ID:Chenguang-Zhu,项目名称:ICE-C5,代码行数:23,代码来源:Main.cs


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