[問題] 自動使用者控制項的集合屬性無法正確編輯

看板C_Sharp作者 (鄉民)時間17年前 (2009/04/01 16:02), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我在用C#開發Mible Windows Form上面的User Control 我的User Control上面有一個我自訂型別的集合屬性, 且該型別有繼承CollectionBase。 目前遇到的狀況是,在Design Time的時候,可以透過屬性, 打開集合編輯器(Collection Editor),編輯器也成功顯示了 幾何所屬物件的所有欄位,我key值進去以後,Design Time的 Form也確實出現了那些值。 可是在Run Time的時候卻一個字都出不來。 我察看.Designer檔,發現了下面的現象 MyControl.Item item1 = new MyControl.Item(); //我在編輯器內對集合加入一個Item item1.Caption = "a"; //我在編輯器內key in的Item屬性 item1.Context = "b"; //同上,另一個屬性 //以上編輯器都沒錯,錯誤在下一行 new MyControl.ItemCollection().Add(item1); //編輯器竟然憑空new一個集合 //常理來說,Items集合應該屬於我的控制項MyListBox //所以應該這樣寫 this.MyListBox1.Items.Add(item1); 請問我該怎麼修正? Item和ItemCollection都已經加上了 [System.ComponentModel.DesignTimeVisible(true)] 估狗大神拜了半天也沒用 給我點提示吧..... -- My Blog: http://aaronmind.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.96.116.10
文章代碼(AID): #19qn-7jc (C_Sharp)