我在列表框中產生了checkboxesat運行時,問題是我怎麼知道選中的複選框是什麼?我如何知道CheckBox被選中?
我嘗試下面的代碼在C#:
CheckBox box;
if (box.Checked)
if (box.IsChecked)
這是下面的代碼:
public partial class Choose_Users
{
Service1Client C = new Service1Client();
Array a;
user_detail d;
String F_Name, L_Name;
CheckBox user = new CheckBox();
public Choose_Users()
{
InitializeComponent();
a = C.GetData();
for (int i = 0; i < a.Length; i++)
{
d = (user_detail)a.GetValue(i);
user.Name = d.First_name;
user.Content= d.First_name;
listBox1.Items.Add(user);
}
}
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
List<user_detail> list = new List<user_detail>();
foreach(CheckBox box in this.listBox1.Items)
{
if (box.Checked // here my problem is
{
}
}
}
}
他們沒有工作。任何幫助?
哪種編程語言? – n00dle 2011-05-30 18:28:42
@Sofia,你發佈了一個問題,它提供了很少的上下文,用於檢查你使用的語言,環境等。請編輯您的問題與相關的細節,並更新標籤,以反映你想要得到答案。 – 2011-05-30 18:29:51
好的,謝謝。它是c# – Sofia 2011-05-30 18:32:10