开发者

.net ComboBox.Items.Add("testvalue") throws exception

开发者 https://www.devze.com 2023-03-08 15:08 出处:网络
I am using Compact Framework and the statement below throws exception: ComboBox cmbList= new ComboBox();

I am using Compact Framework and the statement below throws exception:

 ComboBox cmbList  = new ComboBox();

    //source set here
   List<string> items = new List<string>();
   items.AddRange开发者_开发百科(GetNumbers());     
   cmbList.DataSource = ovenNumbers;


    // where GetNumbers() return List<string> object        
    //then down the road I need to dynamically add one more item to the list of items

     cmbList.Items.Add("TESTVALUE");

MSDN only lists one exception - for null parameter, which is clearly not the case. What am I doing wrong? Thanks!

EDITED: I can't view the error message since I don't have the module required to view errors installed on my thin client.


Found the answer apprently once DataSource property is set,it can't be changed http://msdn.microsoft.com/en-us/library/system.windows.forms.listcontrol.datasource%28v=vs.90%29.aspx

"When the DataSource property is set, a user cannot modify the items collection."


Well are you sure the source is filled with string objects?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号