2
foreach (CheckedListBox item in itemInfoCheckList.Items)
{
if (item.CheckState == CheckState.Checked)
SW.WriteLine(item.Text + " : YES");
else
SW.WriteLine(item.Text + " : NO");
}
上面的代碼片段是它循環......雖然只有2項 下面是iteminfochecklist定義C#:循環永遠的foreach CheckedListBox項目
this.itemInfoCheckList.CheckOnClick = true;
this.itemInfoCheckList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.itemInfoCheckList.FormattingEnabled = true;
this.itemInfoCheckList.Items.AddRange(new object[] {
"item 1 ",
"item 2"});
this.itemInfoCheckList.Location = new System.Drawing.Point(573, 350);
this.itemInfoCheckList.Name = "itemInfoCheckList";
this.itemInfoCheckList.Size = new System.Drawing.Size(197, 38);
this.itemInfoCheckList.TabIndex = 143;
請向我們展示定義/填充itemInfoCheckList的代碼。僅憑循環就不可能做任何事情。 –
問題在哪裏? – Reniuz
該代碼不會進入無限循環。你怎麼確定它是? –