|
目测下,C/S里,不需要bind。B/S里需要bind下吧....C/S里,我一般这么写:
/// <summary>
/// 初始化委托
/// </summary>
/// <param name="method"></param>
private void DeterMineCall(MethodInvoker method)
{
if (InvokeRequired)
{
Invoke(method);
}
else
{
method();
}
}
/// <summary>
/// 添加ListView行
/// </summary>
/// <param name="str">显示文本</param>
/// <param name="color">文本颜色</param>
/// <param name="param">参数,没有填""</param>
private void AddListViewItem(string str, Color color, params object[] param)
{
DeterMineCall(() =>
{
ListViewItem lvi = new ListViewItem();
lvi.SubItems.Add("时间");
lvi.SubItems.Add("信息");
lvi.SubItems[0].Text = DateTime.Now.ToLongTimeString();
lvi.SubItems[1].Text = string.Format(str, param);
lvi.ForeColor = color;
lvconfigip.Items.Insert(0, lvi);
});
}
|
|