/// <summary>
/// 取ListBox选中项id
/// </summary>
/// <returns>id数组</returns>
private int[] GetIDS()
{
int[] id = new int[listBox1.SelectedIndices.Count];
for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
{
id[i] = (int)listBox1.SelectedIndices[i];
}
return id;
}
int[] id = GetIDS();
DataTable dt= (DataTable)listBox1.DataSource;
string str = "";
for (int i = 0; i < id.Length; i++)
{
str += dt.Rows[id[i]]["id"].ToString();
}
MessageBox.Show(str);