我試圖從另一個類訪問我的BindingList,但我不確定如何去做。從另一個類訪問BindingList
這是從我的窗體2類我的代碼:
public partial class Form2 : Form
{
//List containing the memos added
public static BindingList<memo> memosList = new BindingList<memo>();
//Now the list needs to be initialized so i can use it elsewhere
public static BindingList<memo> Memos
{
get { return memosList; }
set { memosList = value; }
}
//...
這裏是代碼從我Form3類:
private void CreateMemo(object sender, EventArgs args)
{
memo memosList = new memo();
memosList.Add(
new memo(priorityNumber.Text, memoTitle.Text, memoDescription.Text));
}
我怎麼會在窗體2訪問列表中,這樣我可以添加/刪除它的項目?
請參見[56,「問題包括‘標籤’,在他們的頭銜?」] (http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles),其中的共識是「不,他們不應該」! –