110,571
社区成员
发帖
与我相关
我的任务
分享
if (!b)
MessageBox.Show(TT);
[/quote]
是不是应该这样的哦
DataTable dtShow = new DataTable();
dtShow = (DataTable)this.form1.dataGridView1.DataSource;
bool b = false;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue == true)//这里把!=改成==
{
b = true;
break;
}
}
if (b)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue == true) //查找被选择的数据行
{
string GoodsCode = dataGridView1.Rows[i].Cells["name"].Value.ToString();
string GoodsName = dataGridView1.Rows[i].Cells["password"].Value.ToString();
MessageBox.Show("选择的物品是:" + GoodsName);
}
}
}
else
{
MessageBox.Show("请选择");
}
if (!b)
MessageBox.Show(TT);
bool b = false;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue != true)
{
b = true;
break;
}
}
if (b)
MessageBox.Show(TT);
bool b = false;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue == true)
{
b = true;
break;
}
}
if (!b)
MessageBox.Show("请选择!");