通过ccheckboxlist循环 [英] looping through a ccheckboxlist
本文介绍了通过ccheckboxlist循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题列表,每个问题都有两个复选框以填充是或否,因此我需要在第一列中循环选择是,在第二列中循环选择否.当我循环时,我必须确保每个问题都得到回答,我只想要是.我该怎么做?.
I''m having a list of questions and each question has two checkbox to fill whether a yes or no.so I need to loop through the checkboxes in the first column for yes and in the second column for no. when i loop i have to make sure every question is answered and i only want the yes. How can i do it?.
推荐答案
一个CheckedListBox
只有一列.你怎么可能有第二个呢?除此之外,为什么只有一列可以达到目的,您为什么会有一列代表是",而另一列代表否"?如果选中,则表示是,如果未选中,则表示否.看来您的CheckListBox
有点过度设计.
ACheckedListBox
only has one column. How is it possible that you have a 2nd one? Beyond that, WHY do you have a column for Yes and another for No, when a single column will server the purpose? If it''s checked, Yes is indicated, and if it''s not checked, No is indicated. Looks like yourCheckListBox
is a little over-engineered.
您可以使用 ^ ].使用datagridview,您可以拥有三列:
-问题
-是列
-没有专栏
这两个布尔列都可以是三态列,因此您可以将它们初始设置为每行未定义(不是true或false),然后用户检查适合该问题的答案.
关于循环等问题,我建议您使用数据表.将所有问题放入数据表(也至少具有这三列),然后使用 ^ ]
用户完成回答问题之后,您的程序将遍历数据表中的所有行,而不是遍历datagridview.因为当数据网格视图中的数据发生更改时基础数据表会更新,所以您不必担心在网格中循环,而数据的格式将是更好".
Instead of trying to use list box could you use a DataGridView[^]. With datagridview you could have three columns:
- The question
- Yes column
- No column
Both of those boolean columns could be threestate columns so that you can set them initially as undefined (not true or false) for each row and the user checks the answer that''s appropriate for the question.
What comes to looping etc, I''d suggest that you would use a datatable. Place all the questions in a datatable (also having at least those three columns) and bind that datatable to the datagridview using DataSource[^]
After the user has finished answering the questions your program would loop through all the rows in the datatable, not the datagridview. Because the underlying datatable is updated when the data changes in the datagridview, you don''t have to worry about looping through the grid and you would have the data in ''better'' format.
这篇关于通过ccheckboxlist循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文