0

I have a problem when i convert Combo Box to an object named Category Category selected = cb.SelectedItem as Category; selected always return null enter image description hereenter image description here Can somebody can explain and fix it?enter image description here

  • Well, is looks like `SelectedItem` is not a `Category` instance. Use the debugger to look at `SelectedItem` and see what type is actually is. – Sean May 14 '20 at 16:47
  • class Category { public Category(int id, string name) { this.ID = id; this.Name = name; } public Category(DataRow row) { this.ID = (int)row["id"]; this.Name = row["name"].ToString(); } private int iD; public int ID { get { return iD; } set { iD = value; } } private string name; public string Name { get { return name; } set { name = value; } } } – Trịnh Cường Quốc Ái May 14 '20 at 16:48

0 Answers0