示例#1
0
        private void txtUsername_TextChanged(object sender, EventArgs e)
        {
            string staffID = (string)dtgvAccount.SelectedCells[0].OwningRow.Cells["Mã nhân viên"].Value;
            Staff  staff   = StaffDAO.GetStaffByID(staffID);//The staff that we're currently selecting

            if (staff == null)
            {
                //The case that nothing on dtgv - no result after searched
                return;
            }

            cboStaffID_Account.SelectedItem = staff;

            int index = -1;
            int i     = 0;

            foreach (Staff item in cboStaffID_Account.Items)
            {
                if (item.ID == staff.ID)
                {
                    index = i;
                    break;
                }
                i++;
            }
            cboStaffID_Account.SelectedIndex = index;
        }