![](/img/trans.png)
[英]C# :How can i set Memory stream as the asp.net image control's source property?
[英]Visual C#, how can I set SetItemChecked property using Control?
我有一個包含幾個CheckedListBox
項目以及其他控件的表單。 我試圖遍歷每個控件並設置其屬性值。 不幸的是, SetItemChecked
類的SetItemChecked
屬性在Control
類中不可用,因此我不知道如何操作控件的Checked
狀態。
這是我到目前為止的內容:
for (int i = 0; i < Controls.Count(); i++) {
switch(Controls[i].GetType().ToString()) {
case "System.Windows.Forms.TextBox":
case "System.Windows.Forms.RichTextBox":
Controls[i].Text=i.ToString();
break;
case "System.Windows.Forms.CheckedListBox":
Controls[i].SetItemChecked(0,true);
// ^^ This line doesn't work, because SetItemChecked is not available
break;
default:
Controls[i].Tag=i;
break;
}
}
您可以像這樣將控件轉換為CheckedListBox:
(Controls[i] as CheckedListBox).SetItemChecked(0,true);
我不確定這一點,但它也可能起作用:
CheckedListBox myCbList= (ChecekdListBox) Controls[i];
myCbList.SetItemChecked(0,true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.