比较Datagridview中的多个值

时间:2016-12-06 05:40:07

标签: c#

enter image description here

在按钮单击事件上,我想基于类别循环遍历行。如果Datagridview一次包含带框架,镜头和咨询的类别。然后我想要显示警报。怎么做到这一点?我试过foreach但没有结果。

tsudpreceive 239.1.1.1 50000 > input.ts &
tsudpsend input.ts 224.5.5.5 5000 3000000 &

1 个答案:

答案 0 :(得分:1)

循环所有记录并保留给定列表中的项目标记。如果所有标志都为真,最后显示消息

bool frame,lens,type;

foreach (DataGridViewRow row in dataGridViewInvoice.Rows)
{
    string ItemType = row.Cells["SubCategory"].Value.ToString();
    if(ItemType == "Frame"){frame =true;}
    else if ( ItemType == "Lens"){lens =true;}
    else if (ItemType == "Consultation"){type =true;}
}
if (frame && lens && type)
{
       MessageBox.Show("You can't select all items at once");
}