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


C# ListBox.Invoke方法代码示例

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


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

示例1: AddItemToListBox

        public static void AddItemToListBox(ListBox listBox, string text)
        {
            // Check if the listbox need to be invoked.
            if (listBox.InvokeRequired)
                // Invoke the listbox control with the appropiate delegate.
                listBox.Invoke(new Action<ListBox, string>(AddItemToListBox), listBox, text);
            else
            {
                // Declare and instantiate a list for the listboxes item in the form of strings.
                List<string> listListBox = new List<string>();

                // Add the newest string to the newly created list, so that this is on top.
                listListBox.Add(text);

                // Add all of the current items to the list.
                foreach (string item in listBox.Items)
                    listListBox.Add(item);

                // Clear the listbox of all of its items.
                listBox.Items.Clear();

                // Add the newly created list to the listbox.
                foreach (string item in listListBox)
                    listBox.Items.Add(item);
            }
        }
开发者ID:Woodje,项目名称:MailClient,代码行数:26,代码来源:ComponentChanges.cs

示例2: ClearItemFromListBox

 public static void ClearItemFromListBox(ListBox listBox)
 {
     // Check if the listbox need to be invoked.
     if (listBox.InvokeRequired)
         // Invoke the listbox control with the appropiate delegate.
         listBox.Invoke(new Action<ListBox>(ClearItemFromListBox), listBox);
     else
         // Directly clear the listbox.
         listBox.Items.Clear();
 }
开发者ID:Woodje,项目名称:MailClient,代码行数:10,代码来源:ComponentChanges.cs

示例3: debug_

 public void debug_(ListBox listBoxToUpdate, object data)
 {
     if (listBoxToUpdate.InvokeRequired)
       {
     debugDelegate dd = new debugDelegate(debug_);
     listBoxToUpdate.Invoke(dd, new object[] { listBoxToUpdate, data });
       }
       else
       {
     int i = listBoxToUpdate.Items.Add(DateTime.Now.ToShortTimeString() + " : " + data);
     listBoxToUpdate.TopIndex = i;
       }
 }
开发者ID:tomvdb,项目名称:goodFET-csharp-concept,代码行数:13,代码来源:Form1.cs

示例4: RemoveItemAt

            public static void RemoveItemAt(ListBox listbox, int index)
            {
                MethodInvoker miRemoveItem = delegate
                {
                    listbox.Items.RemoveAt(index);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miRemoveItem);
                }
                else
                {
                    miRemoveItem();
                }
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ListBoxDelegates.cs

示例5: InsertItem

            public static void InsertItem(ListBox listbox, int index, object item)
            {
                MethodInvoker miInsertItem = delegate
                {
                    listbox.Items.Insert(index, item);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miInsertItem);
                }
                else
                {
                    miInsertItem();
                }
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ListBoxDelegates.cs

示例6: AddItem

        public static void AddItem(ListBox box, string item)
        {
            MethodInvoker miAddItem = delegate
            {
                box.Items.Add(item);
            };

            if (box.InvokeRequired)
            {
                box.Invoke(miAddItem);
            }
            else
            {
                miAddItem();
            }
        }
开发者ID:yodelmas,项目名称:XrmToolBox,代码行数:16,代码来源:MainControl.cs

示例7: ClearItems

            public static void ClearItems(ListBox listbox)
            {
                MethodInvoker miClearItems = delegate
                {
                    listbox.Items.Clear();
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miClearItems);
                }
                else
                {
                    miClearItems();
                }
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ListBoxDelegates.cs

示例8: AddItem

            public static void AddItem(ListBox listbox, object item)
            {
                MethodInvoker miAddItem = delegate
                {
                    listbox.Items.Add(item);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miAddItem);
                }
                else
                {
                    miAddItem();
                }
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ListBoxDelegates.cs

示例9: FetchAttendees

        internal static void FetchAttendees(User i_LoggedInUser, ListBox i_ListBoxFriendsWithRank)
        {
            List<UserRank<Event>> allUsersWithSharedEvents = CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList;
            if (allUsersWithSharedEvents == null)
            {
                allUsersWithSharedEvents = FetchAttendeesFromEvents(i_LoggedInUser);
                CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList = allUsersWithSharedEvents;
            }

            ArrayList userRankList = new ArrayList(allUsersWithSharedEvents);
            userRankList.Sort();
            userRankList.Reverse();
            foreach (UserRank<Event> userRank in userRankList)
            {
                i_ListBoxFriendsWithRank.Invoke(new Action(() => i_ListBoxFriendsWithRank.Items.Add(userRank)));
            }
        }
开发者ID:OrSi333,项目名称:FacebookApp,代码行数:17,代码来源:FBSpecialFeatures.cs

示例10: GetItem

            public static object GetItem(ListBox listbox, int index)
            {
                object item = null;

                MethodInvoker miRemoveItem = delegate
                {
                    item = listbox.Items[index];
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miRemoveItem);
                }
                else
                {
                    miRemoveItem();
                }

                return item;
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:20,代码来源:ListBoxDelegates.cs

示例11: GetSelectedItem

            public static object GetSelectedItem(ListBox listbox)
            {
                object selectedItem = null;

                MethodInvoker miClearItems = delegate
                {
                    selectedItem = listbox.SelectedItem;
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miClearItems);
                }
                else
                {
                    miClearItems();
                }

                return selectedItem;
            }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:20,代码来源:ListBoxDelegates.cs

示例12: ShowStat

        private void ShowStat(ListBox lstBox, string str)
        {
            if (lstBox.InvokeRequired)
            {
                ShowStatCallBack ShowStatCallBack = ShowStat;
                lstBox.Invoke(ShowStatCallBack, new object[] { lstBox, str });
            }
            else
            {

                if (str.Equals("finish-all"))
                {
                    buttonSyncIni.Enabled = true;
                    int nIdex = lstBox.Items.Add(str);
                    bSyncing = false;
                }
                else if (str.Equals("finish-diff"))
                {
                    buttonSyncDiff.Enabled = true; int nIdex = lstBox.Items.Add(str);
                }
                else
                {
                    int nIdex = 0;
                    if (str.Length == 0)
                    {
                        nIdex = lstBox.Items.Add("");
                    }
                    else
                    {
                        string sLine = DateTime.Now.ToString("mm:ss") + " " + str;
                        nIdex = lstBox.Items.Add(sLine);
                        //�������ײ�
                        listBox1.SelectedIndex = nIdex; //  listBox1.SelectedIndex = -1;
                    }
                    if (nIdex > 1000)
                        listBox1.Items.Clear();
                }
            }
        }
开发者ID:chutinhha,项目名称:asset-management-system,代码行数:39,代码来源:Read2PcForm.cs

示例13: addTextLine

 public void addTextLine(ListBox Destination, String newLine)
 {
     if(Destination.InvokeRequired)
         Destination.Invoke(new del_addText(addTextLine), Destination, newLine);
     else
     {
         Destination.Items.Add(newLine);
         Destination.SelectedIndex = lbEddnImplausible.Items.Count-1;
         Destination.SelectedIndex = -1;
     }
 }
开发者ID:carriercomm,项目名称:ED-IBE,代码行数:11,代码来源:Form1.cs

示例14: ListBoxFill

 private void ListBoxFill(ListBox listbox, string[] entries)
 {
     if (listbox.InvokeRequired)
     {
         listbox.Invoke(new ListBoxModifyCall(ListBoxFill), new object[] { listbox, entries, });
     }
     else
     {
         listbox.Items.Clear();
         listbox.Items.AddRange(entries);
     }
 }
开发者ID:quicklywilliam,项目名称:circle-of-current,代码行数:12,代码来源:Server.cs

示例15: AddLog2List

 public static void AddLog2List(ListBox lstAct, string content)
 {
     try
     {
         if (lstAct.InvokeRequired)
         {
             lstAct.Invoke(new AddLog(AddLog2List), new object[] { lstAct, content });
         }
         else
         {
             lstAct.BeginUpdate();
             lstAct.Items.Add(content);
             lstAct.EndUpdate();
         }
     }
     catch
     {
     }
 }
开发者ID:khaha2210,项目名称:radio,代码行数:19,代码来源:CommonLibrary.cs


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