public win_hopper(DesignerCanvas a, bool isnew = false) { hopperitem = new Dev_Hopper(a.GetPositionID(DesignerCanvas.DeviceType.DEV_HOPPER)); InitializeComponent(); isNew = isnew; this.DataContext = this.hopperitem; for (int i = 0; i < this.cb_type.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_type.Items[i] as ComboBoxItem).Tag, 16); if (value == hopperitem.Powder_type) { this.cb_type.SelectedIndex = i; break; } } for (int i = 0; i < this.cb_max_cap.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_max_cap.Items[i] as ComboBoxItem).Tag, 10); if (value == hopperitem.Max_capability) { this.cb_max_cap.SelectedIndex = i; break; } } }