本文整理匯總了C#中System.Windows.Forms.ListBox.BeginInvoke方法的典型用法代碼示例。如果您正苦於以下問題:C# ListBox.BeginInvoke方法的具體用法?C# ListBox.BeginInvoke怎麽用?C# ListBox.BeginInvoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.ListBox
的用法示例。
在下文中一共展示了ListBox.BeginInvoke方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CrossThreadClearListboxItem
/// <summary>
/// 跨線程清除listbox的item
/// </summary>
/// <param name="lb"></param>
public void CrossThreadClearListboxItem(ListBox lb)
{
if (lb.InvokeRequired)
{
DelegateforClearListboxItem del = new DelegateforClearListboxItem(CrossThreadClearListboxItem);
lb.BeginInvoke(del, new object[] { lb });
}
else
{
lb.Items.Clear();
}
}
示例2: Remove
public void Remove(ClientInfo item, ListBox list)
{
if (list.InvokeRequired)
{
list.BeginInvoke(new MethodInvoker(delegate
{
Remove(item, list);
}));
}
else
{
list.Items.Remove(item);
}
}
示例3: GetSelectedListBoxIdx
public string GetSelectedListBoxIdx(ListBox anything, int idx)
{
string rStr = string.Empty;
anything.BeginInvoke((MethodInvoker)delegate
{
try
{
rStr = (string) anything.Items[idx];
}
catch
{
}
});
return rStr;
}
示例4: SetSelectedListBoxIdx
public void SetSelectedListBoxIdx(ListBox anything, int idx, bool state)
{
anything.BeginInvoke((MethodInvoker)delegate
{
try
{
anything.SetSelected(idx, state);
}
catch
{
}
});
}
示例5: CrossTreadAddItemtoListbox
/// <summary>
/// 實現跨線程插入到Listbox中數據的函數
/// </summary>
/// <param name="lb"></param>
/// <param name="strMsg"></param>
public void CrossTreadAddItemtoListbox(ListBox lb, string strMsg)
{
if (lb.InvokeRequired)
{
DelegateforAddItemToListbox del = new DelegateforAddItemToListbox(CrossTreadAddItemtoListbox);
lb.BeginInvoke(del, new object[] { lb, strMsg });
}
else
{
lb.Items.Add(strMsg);
}
}
示例6: ShowInfoProc
private void ShowInfoProc(string strMsg, ListBox lstBox, int nMax)
{
lstBox.BeginInvoke((Action)delegate ()
{
lstBox.BeginUpdate();
lstBox.Items.Add(strMsg);
if (nMax > 0)
{
while (lstBox.Items.Count > nMax)
lstBox.Items.RemoveAt(0);
}
// Scroll to end
//
lstBox.SelectedIndex = lstBox.Items.Count - 1;
lstBox.EndUpdate();
});
}
示例7: ListboxItemsInsert
private void ListboxItemsInsert(ListBox lb, string strVal)
{
if (lb.InvokeRequired)
{
dListboxItemsInsert d = new dListboxItemsInsert(ListboxItemsInsert);
lb.BeginInvoke(d, new object[] { lb, strVal });
}
else
{
lb.Items.Add(strVal);
}
}
示例8: ListBoxItemsDelete
private void ListBoxItemsDelete(ListBox lb)
{
if (lb.InvokeRequired)
{
dListBoxItemsDelete d = new dListBoxItemsDelete(ListBoxItemsDelete);
lb.BeginInvoke(d, new object[] { lb });
}
else
{
lb.Items.Clear();
}
}