本文整理汇总了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);
}
}
示例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();
}
示例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;
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例7: ClearItems
public static void ClearItems(ListBox listbox)
{
MethodInvoker miClearItems = delegate
{
listbox.Items.Clear();
};
if (listbox.InvokeRequired)
{
listbox.Invoke(miClearItems);
}
else
{
miClearItems();
}
}
示例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();
}
}
示例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)));
}
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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;
}
}
示例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);
}
}
示例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
{
}
}