Sorry for my new question, but I have problem: I want to add combobox items with databinding, but see NullException ("Object reference not set to an instance of an object."), but I have data in table. This is my code:
BesenicaDataSet ds = new BesenicaDataSet();
ds.ReadXml("BesenicaDS.xml");
comboBox1.DataSource = ds.Tables["Kategorii"].DefaultView;
comboBox1.DisplayMember = "Kategoriq";
更新:
现在,我用这个修了它 无法破例
comboBox1 = new ComboBox();
comboBox1.DataSource = ds.Tables["Kategorii"].DefaultView;
comboBox1.DisplayMember = "Kategoriq"; //second column in table
comboBox1.ValueMember = "KategoriqID"; //Primary Key column
但是现在ComboBox1.Trounds.Counts.Count = = 0,但我在这个桌子上有东西。为什么和如何修复它?