private void cboupdCD_SelectedIndexChanged(object sender, EventArgs e) { if (cboupdCD.SelectedIndex == -1) { return; } CD updCD = new CD(); //updCD.getCD(Convert.ToInt32(cboupdCD.Text.Substring(0, 3))); updCD.getCD(Convert.ToInt32(cboupdCD.Text.Substring(0, 4))); if (updCD.getCDID().Equals(0)) { MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCDID.Focus(); return; } //display Stock details txtCDID.Text = updCD.getCDID().ToString("00000"); txtUAlbum.Text = updCD.getAlbumName(); txtUArtist.Text = updCD.getArtist().ToString(); txtYr.Text = updCD.getYr().ToString(); txtUArtistLbl.Text = updCD.getArtLabel(); txtUCostPrice.Text = updCD.getCostPrice().ToString(); txtuQty.Text = updCD.getQty().ToString(); cboSuppliers.SelectedItem = updCD.getSuppID().ToString("000"); DataSet ds = new DataSet(); ds = Supplier.getAllActiveSuppliers(ds); //load suppliers for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboSuppliers.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + ds.Tables[0].Rows[i][1].ToString()); } int theSuppID = updCD.getSuppID(); cboSuppliers.SelectedIndex = 0; while (!cboSuppliers.Text.Substring(0, 3).Equals(theSuppID.ToString("000"))) { cboSuppliers.SelectedIndex++; } grpUCD.Visible = true; }