private void FrmInventory_Load(object sender, EventArgs e) { DataRowView rowView = (DataRowView)cmbDept.SelectedItem; string DeptId = rowView.Row[Const.Department.Dept_ID].ToString(); DataTable InventoryByDepart = get_service.GetAllInventoryByDept_Button(StaticClass.ScheduleIndex, DeptId, StaticClass.storeId); changeState(InventoryByDepart, currentIndex); inventory = get_service.GetAllInventory(StaticClass.storeId); limit = inventory.Rows.Count - 1; //get current index of Cmb in departs for (int j = 0; j < InventoryByDepart.Rows.Count; j++) { DataRowView tmp = (DataRowView)cmbDept.SelectedItem; if (tmp.Row[0].Equals(departs.Rows[j][7])) { currentIndex = j; break; } } }