关于在datagridview控件中选取的几列值的选取与得值问题
//if (dataGridView1.SelectedRows[0].Selected)//{
// order = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
//}
//MessageBox.Show(order);
string billno = "";
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[0].Value != null)
{
if ((bool)dataGridView1.Rows[i].Cells[0].Value == true)
{
billno += dataGridView1.SelectedRows[0].Cells[2].Value.ToString() + ",";
//billno += dataGridView1.Rows[i].Cells[i].Value.ToString() + ",";
//MessageBox.Show(billno);
}
}
}
MessageBox.Show(billno);
//}
if (!string.IsNullOrEmpty(billno))
{
billno = billno.Remove(billno.LastIndexOf(","), 1);
}
当选取两行的时候messagebox输出的是选取的第二行的值,并且还是输出的两次,第二行是订单号比如是 02 那输出就是02,02