c# checkbox数组
时间: 2023-10-20 18:59:14 浏览: 184
回答: 在C#中,可以使用数组和循环来生成一组CheckBox控件,并将已知的一个数组初始化到CheckBox的Text属性中。以下是一个示例代码:
```csharp
Boolean[] 数据组 = { true, false, false, true, false, true };
CheckBox[] 控件组 = Array.ConvertAll(数据组, 控件 => new CheckBox());
int 数 = 数据组.Length;
foreach (CheckBox 多选 in 控件组)
{
多选.Text = (数--).ToString("多选00");
多选.Name = 数.ToString("多选00");
多选.Parent = this;
多选.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
多选.Location = new Point(100 * 数, 22);
多选.Checked = 数据组<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [c# 代码生成6个checkbox 并初始化已知的一个数组到checkboxtext内](https://blog.csdn.net/xianfajushi/article/details/41645137)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [C#为ComboBox等数组型控件设置自定义数据](https://blog.csdn.net/a_dev/article/details/83302337)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)