change your check partial code to this :
for (int k = 0; k < dgvAddrecords.Rows.Count -1; k++)
{
if(this.dgvAddrecords.Rows[k].Cells[7].Value!=null)
if (this.cboYear2.Text == this.dgvAddrecords.Rows[k].Cells[7].Value.ToString() )
{
MessageBox.Show("The Year exsist, Please select a new year");
return;
}
}
dgvAddrecords.Rows.Add(txtCode2.Text, dtpDate.Text, txtName2.Text, txtOwnersnane.Text, cboRatetype.Text, txtDistrict.Text, txtTown.Text, cboYear2.Text, txtYearlydues.Text);
int sum = 0;
for (int i = 0; i < dgvAddrecords.Rows.Count; ++i)
{
sum += Convert.ToInt32(dgvAddrecords.Rows[i].Cells[8].Value);
}
txtAmountdue.Text = sum.ToString();