本文整理汇总了C#中System.Windows.Forms.ListView.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Invoke方法的具体用法?C# ListView.Invoke怎么用?C# ListView.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddChecked
public void AddChecked(IEnumerable<string> list, ListView listView)
{
if (list == null)
{
return;
}
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(16, 16);
imageList.ColorDepth = ColorDepth.Depth32Bit;
// Add a default image at position 0;
imageList.Images.Add(Properties.Resources.Tick_16x16);
var pagelist = list.ToArray();
ListViewItem[] items = new ListViewItem[pagelist.Length];
for (int i = 0; i < pagelist.Length; i++)
{
ListViewItem item = new ListViewItem(pagelist[i].Substring(pagelist[i].LastIndexOf('.') + 1));
item.ImageIndex = 0;
items[i]= item;
}
listView.Invoke((Action)(() =>
{
listView.LargeImageList = imageList;
listView.SmallImageList = imageList;
listView.BeginUpdate();
listView.Items.Clear();
listView.Items.AddRange(items);
listView.EndUpdate();
}));
}
示例2: AddListViewData
//添加单行数据
public void AddListViewData(ListView list, Dictionary<string, string> data)
{
if (list.InvokeRequired)//不能访问就创建委托
{
ListViewDelegate d = new ListViewDelegate(AddListViewData);
list.Invoke(d, new object[] { list, data });
}
else
{
list.BeginUpdate();
ListViewItem list_item = new ListViewItem();
bool need_init = true;
foreach (KeyValuePair<string, string> cell in data)
{
ListViewItem.ListViewSubItem list_sub_item = new ListViewItem.ListViewSubItem();
if (need_init)
{
list_item.Text = cell.Value;
need_init = false;
}
else
{
list_sub_item.Text = cell.Value;
list_item.SubItems.Add(list_sub_item);
}
}
list.Items.Add(list_item);
list.EnsureVisible(list.Items.Count - 1);
list.EndUpdate();
}
}
示例3: RefreshUpdate
public void RefreshUpdate(ListView listview, TabPage tab)
{
getpack = new GetPackage(packages);
IEnumerable<IPackage> localPackages = getpack.GetPackagesFromExtensions(App.Extensions);
if (localPackages.Count() > 0)
{
IEnumerable<IPackage> list = null;
try
{
list = packages.Repo.GetUpdates(localPackages, false, false);
}
catch (WebException)
{
listview.Invoke((Action)(() =>
{
listview.Clear();
listview.Items.Add("Updates could not be retrieved for the selected feed.");
listview.Items.Add("Try again later or change the feed.");
}));
}
listview.Invoke((Action)(() =>
{
listview.Clear();
int Count = list.Count();
tab.Text = String.Format("Updates ({0})", Count);
Add.AddPackages(list, listview, 0);
if (listview.Items.Count == 0)
{
listview.Clear();
listview.Items.Add("No updates available for the selected feed.");
}
}));
}
else
{
listview.Invoke((Action)(() =>
{
listview.Clear();
listview.Items.Add("No packages are installed.");
}));
}
}
示例4: AddItem
/// <summary>
/// Główna funkcja inicjująca listView.
/// </summary>
/// <param name="columnList">Tablica określająca kolumny listView.</param>
/// <param name="className">Nazwa listy.</param>
public static void AddItem(ListView listView, string[] item)
{
if (listView.InvokeRequired)
{
AddItemDelegate del = new AddItemDelegate(AddItem);
listView.Invoke(del, listView, item);
return;
}
listView.Items.Add(ConvertToItem(item));
}
示例5: AdjustColumnWidth
/// <summary>
/// Dopasowywuje szerokość kolumn listy do najszerszego elementu.
/// </summary>
/// <param name="listView">Lista, której kolumny są dopasowywane.</param>
public static void AdjustColumnWidth(ListView listView)
{
if (listView.InvokeRequired)
{
AdjustColumnsDelegate del = new AdjustColumnsDelegate(AdjustColumnWidth);
listView.Invoke(del, listView);
return;
}
foreach (ColumnHeader column in listView.Columns)
column.Width = -2;
}
示例6: InvokeAddListViewItems
/// <summary>
/// Invoke方式添加ListView控件的Item选项
/// </summary>
public static void InvokeAddListViewItems(ListView listView, ListViewItem item)
{
if (listView.InvokeRequired)
{
listView.Invoke(new MethodInvoker(delegate() { InvokeAddListViewItems(listView, item); }));
}
else
{
listView.Items.Add(item);
}
}
示例7: InvokeClearListViewItems
/// <summary>
/// Invoke方式清空ListView控件的Items属性
/// </summary>
public static void InvokeClearListViewItems(ListView listView)
{
if (listView.InvokeRequired)
{
listView.Invoke(new MethodInvoker(delegate() { InvokeClearListViewItems(listView); }));
}
else
{
listView.Items.Clear();
}
}
示例8: AddToListView
public void AddToListView(ListView Info, ListViewItem Item)
{
if (Info.InvokeRequired)
{
ListViewDelegate DDD = new ListViewDelegate(AddToListView);
Info.Invoke(DDD, new object[] { Info, Item });
}
else
{
Info.Items.Add(Item);
}
}
示例9: BuildAlertList
public void BuildAlertList(ListView lv)
{
if (lv.InvokeRequired)
{
BuildAlertListCallback d = new BuildAlertListCallback(BuildAlertList);
lv.Invoke(d, new object[] { lv });
}
else
{
lv.Items.Clear();
}
}
示例10: updateListView
public static void updateListView(ListView lvToUse, ListViewItem lvItemToAdd)
{
if (lvToUse.InvokeRequired)
{
updateListViewCallback ulvCallback = new updateListViewCallback(updateListView);
lvToUse.Invoke(ulvCallback, new object[] { lvToUse, lvItemToAdd });
}
else
{
lvToUse.Items.Insert(0, lvItemToAdd);
}
}
示例11: ListViewTo
public void ListViewTo(ListView Info, ref string[] destination)
{
if (Info.InvokeRequired)
{
LVToDelegate DDD = new LVToDelegate(ListViewTo);
Info.Invoke(DDD, new object[] { Info, destination });
}
else
{
listBox1.Items.CopyTo(destination, 0);
}
}
示例12: AddItemToList
public void AddItemToList(ListViewItem itm, ListView lst)
{
if (lst.InvokeRequired)
{
AccessControlListCallback d = new AccessControlListCallback(AddItemToList);
lst.Invoke(d, new object[] { itm, lst });
}
else
{
lst.Items.Add(itm);
}
}
示例13: ClearListview
private void ClearListview(ListView o)
{
if (o.InvokeRequired)
{
o.Invoke(new Action<ListView>(ClearListview), new object[] { o });
}
else
{
o.Items.Clear();
}
}
示例14: ClearListView
/// <summary>
/// Czyszczenie listView.
/// </summary>
/// <param name="listView">Element ListView do wyczyszczenie.</param>
/// <returns>Zwracanie czystej ListView.</returns>
public static ListView ClearListView(ListView listView)
{
if (listView.InvokeRequired)
{
InvokeClearLV del = new InvokeClearLV(ClearListView);
listView.Invoke(del, listView);
return listView;
}
listView.BeginUpdate();
listView.Items.Clear();
listView.EndUpdate();
return listView;
}
示例15: AddGroupsRange
public static void AddGroupsRange(ListView listview, ListViewGroup[] groups)
{
MethodInvoker miAddItem = () => listview.Groups.AddRange(groups);
if (listview.InvokeRequired)
{
listview.Invoke(miAddItem);
}
else
{
miAddItem();
}
}