如何通一的CheckBoxList,并找到什么检查,不检查回路回路、CheckBoxList

2023-09-03 00:45:54 作者:青春荒唐我不负你*

我试图环通一个复选框列表中的项目。如果它被选中,我要设置1的值。如果没有,我想设置其他值。我用的是下面的,但它只是给我检查的项目:

 的foreach(DataRowView的myRow在clbIncludes.CheckedItems)
{
    MarkVehicle(myRow);
}
 

TIA!

解决方案

 的for(int i = 0; I< clbIncludes.Items.Count;我++)
  如果(clbIncludes.GetItemChecked(i))的
    //做选择的东西
  其他
    //做未选择的东西
 

如果该检查是在不确定状态,这仍然会返回true。您可能要替换

 如果(clbIncludes.GetItemChecked(I))
 
在电器接地的触电示意图中,电流怎么通过人体 电网与大地之间的电容构成回路 这个电容是怎么形成的

 如果(clbIncludes.GetItemCheckState(一)== CheckState.Checked)
 

如果你想只包括实际检查的项目

i'm trying to loop thru items of a checkbox list. if it's checked, I want to set 1 value. If not, I want to set another value. I was using the below but it only gives me checked items:

foreach (DataRowView myRow in clbIncludes.CheckedItems)
{
    MarkVehicle(myRow);
}

TIA!

解决方案

for (int i = 0; i < clbIncludes.Items.Count; i++)
  if (clbIncludes.GetItemChecked(i))
    // Do selected stuff
  else
    // Do unselected stuff

If the the check is in indeterminate state, this will still return true. You may want to replace

if (clbIncludes.GetItemChecked(i))

with

if (clbIncludes.GetItemCheckState(i) == CheckState.Checked)

if you want to only include actually checked items.

 
精彩推荐
图片推荐