本文整理汇总了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();
}
}