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


C# ListView.Invoke方法代码示例

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

示例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();

            }
        }
开发者ID:zhujunxxxxx,项目名称:TaokeThief,代码行数:33,代码来源:Form1.cs

示例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.");
                }));
            }
        }
开发者ID:nikson898,项目名称:dot-spatial,代码行数:43,代码来源:Update.cs

示例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));
 }
开发者ID:nacss,项目名称:main,代码行数:15,代码来源:ListViewConfig.cs

示例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;
 }
开发者ID:nacss,项目名称:main,代码行数:15,代码来源:ListViewConfig.cs

示例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);
     }
 }
开发者ID:yienit,项目名称:KST,代码行数:14,代码来源:UIInvokeUtil.cs

示例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();
     }
 }
开发者ID:yienit,项目名称:KST,代码行数:14,代码来源:UIInvokeUtil.cs

示例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);
     }
 }
开发者ID:Cagyo,项目名称:domain-checker,代码行数:12,代码来源:Form1.cs

示例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();
     }
 }
开发者ID:systeminsights,项目名称:mtcdemoapp,代码行数:12,代码来源:ThreadSafeUIAccessors.cs

示例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);
     }
 }
开发者ID:asr340,项目名称:owasp-code-central,代码行数:12,代码来源:GUI.cs

示例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);
     }
 }
开发者ID:Cagyo,项目名称:domain-checker,代码行数:12,代码来源:Form1.cs

示例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);
     }
 }
开发者ID:santhotech,项目名称:MtConnectAgentDataSimulator,代码行数:12,代码来源:ThreadSafeUIAccessors.cs

示例13: ClearListview

        private void ClearListview(ListView o)
        {
            if (o.InvokeRequired)
            {
                o.Invoke(new Action<ListView>(ClearListview), new object[] { o });
            }

            else
            {
                o.Items.Clear();
            }
        }
开发者ID:wfsiew,项目名称:NeuralNetwork,代码行数:12,代码来源:MainForm.cs

示例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;
 }
开发者ID:rafaliusz,项目名称:main,代码行数:18,代码来源:ListViewConfig.cs

示例15: AddGroupsRange

        public static void AddGroupsRange(ListView listview, ListViewGroup[] groups)
        {
            MethodInvoker miAddItem = () => listview.Groups.AddRange(groups);

            if (listview.InvokeRequired)
            {
                listview.Invoke(miAddItem);
            }
            else
            {
                miAddItem();
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:13,代码来源:ListViewDelegates.cs


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