本文整理汇总了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();
}
示例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();
}
示例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();
}