通过ccheckboxlist循环 [英] looping through a ccheckboxlist

查看:75
本文介绍了通过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有点过度设计.
A CheckedListBox 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 your CheckListBox is a little over-engineered.


您可以使用数据源 [
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆