我在C#中的WPF頁面的代碼listbox.selected錯誤
listBox1.Items[i].Selected = !listBox1.Items[i].Selected;
和我得到這個錯誤:
Error CS1061 'object' does not contain a definition for 'Selected' and no extension method 'Selected' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) samacrm D:\new\samacrm\samacrm\message.xaml.cs 53 Active
還我測試listBox1.SetSelected(我,真);但我有錯誤 我該怎麼辦?
'listBox1.Items [i]'沒有它的屬性'Selected' ... – ediblecode
似乎這條線在循環中,listBox中的item對象通常是一個字符串,所以它沒有選定的屬性。發佈你的循環代碼,所以我們可以理解你真正想要做什麼 – Youssef13
根據你編輯的問題,你會得到什麼錯誤'listBox1.SetSelected(i,true);'? – Youssef13