// 全选 private void all_Click( object sender, EventArgs e) ... { if (this.lstpcik.Items.Count == 0) ...{ return; } data.manufacturerID = Comm.manufacturerID; DataTable dts = us.getDxpt_manufactureuserInfo(data).Tables[0]; DataTable dt = (DataTable)lstpicked.DataSource; if (dt != null) ...{ if (dt.Rows.Count != 0) ...{ for (int i = dt.Rows.Count; i > 0; i--) ...{ dt.Rows.Remove(dt.Rows[i - 1]); } } dt = null; } dt = new DataTable(); dt.Columns.Add("userName"); dt.Columns.Add("phone"); for (int i = 0; i < lstpcik.Items.Count; i++) ...{ DataRow dr = dt.NewRow(); dr[0] = dts.Rows[i][1].ToString(); dr[1] = dts.Rows[i][2].ToString(); dt.Rows.Add(dr); } this.lstpicked.DataSource = dt; this.lstpicked.DisplayMember = "userName"; this.lstpicked.ValueMember = "phone"; } // 右移 private void right_Click( object sender, EventArgs e) ... { if (this.lstpcik.Items.Count == 0) ...{ return; } DataTable dt = (DataTable)lstpicked.DataSource; if (dt == null) ...{ dt = new DataTable(); dt.Columns.Add("userName"); dt.Columns.Add("phone"); } DataRow[] drCheck = dt.Select(" phone = '" + lstpcik.SelectedValue.ToString() + "'"); if(drCheck.Length == 0) ...{ DataRow dr = dt.NewRow(); dr[0] = lstpcik.Text; dr[1] = lstpcik.SelectedValue.ToString(); dt.Rows.Add(dr); } this.lstpicked.DataSource = dt; this.lstpicked.DisplayMember = "userName"; this.lstpicked.ValueMember = "phone";} // 左移 private void left_Click( object sender, EventArgs e) ... {DataTable dt = (DataTable)lstpicked.DataSource; if (dt == null) ...{ return; } if (dt.Rows.Count == 0) ...{ return; } DataRow[] drCheck = dt.Select(" phone = '" + lstpicked.SelectedValue.ToString() + "'"); if (drCheck.Length == 0) ...{ return; } DataRow dr = drCheck[0]; dt.Rows.Remove(dr); this.lstpicked.DataSource = dt; this.lstpicked.DisplayMember = "userName"; this.lstpicked.ValueMember = "phone"; } // 全部移除 private void del_Click( object sender, EventArgs e) ... { DataTable dt = (DataTable)lstpicked.DataSource; if (dt == null) ...{ return; } if (dt.Rows.Count == 0) ...{ return; } for (int i = dt.Rows.Count; i > 0; i--) ...{ dt.Rows.Remove(dt.Rows[i-1]); } }