void DeleteVATCode(string sCode) { if (MessageBox.Show("To delete a VAT code, you must have another code that items belonging to the old code can use. Also, any other changes will first be saved. Continue?", "VAT Code Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { Save(); frmSingleInputBox fsiGetNewCode = new frmSingleInputBox("Enter the code of the VAT rate replacing " + sCode, ref sEngine); fsiGetNewCode.ShowDialog(); if (fsiGetNewCode.Response != "$NONE") { if (sCode != fsiGetNewCode.Response) { bool bFound = false; for (int i = 0; i < tbCodes.Length; i++) { if (fsiGetNewCode.Response.ToUpper() == tbCodes[i].Text.ToUpper()) { bFound = true; break; } } if (bFound) { sEngine.ChangeItemsVATCodes(sCode, fsiGetNewCode.Response); int nCodeLoc = -1; for (int i = 0; i < tbCodes.Length; i++) { if (tbCodes[i].Text.ToUpper() == sCode) { nCodeLoc = i; break; } } if (nCodeLoc != -1) { for (int i = nCodeLoc; i < tbCodes.Length - 1; i++) { tbCodes[i].Text = tbCodes[i + 1].Text; tbNames[i].Text = tbNames[i + 1].Text; tbRates[i].Text = tbRates[i + 1].Text; } this.Controls.Remove(tbCodes[tbCodes.Length - 1]); this.Controls.Remove(tbNames[tbNames.Length - 1]); this.Controls.Remove(tbRates[tbRates.Length - 1]); Array.Resize <TextBox>(ref tbCodes, tbCodes.Length - 1); Array.Resize <TextBox>(ref tbNames, tbNames.Length - 1); Array.Resize <TextBox>(ref tbRates, tbRates.Length - 1); this.Height -= tbCodes[0].Height; } } } } } }