Firstly I personally dislike cross-validation between controls on the validating events of each of the controls - it's a little bit too easy to get into a right mess where you have to enter valid data before you can even exit the form - be careful of this (My personal preference is cross-validation on a specific event on say a button push - "Ok" or "Submit")
Having said that ... something like this should work...
A generic validation function
private bool InvalidYear(object sender)
{
ComboBox cb = (ComboBox)sender;
int cbNum = int.Parse(cb.Name.Replace("comboBox", ""));
ComboBox prev = null, post = null;
if (cbNum > 1)
prev = (ComboBox)this.Controls.Find("comboBox" + (cbNum - 1).ToString(), true)[0];
if (cbNum < 4)
post = (ComboBox)this.Controls.Find("comboBox" + (cbNum + 1).ToString(), true)[0];
bool errorFound = false;
if (prev != null && prev.Text != "")
{
if (cb.Text.CompareTo(prev.Text) <= 0)
errorFound = true;
}
if (post != null && post.Text != "")
{
if (cb.Text.CompareTo(post.Text) >= 0)
errorFound = true;
}
if (errorFound) MessageBox.Show("Invalid year");
return errorFound;
}
And then you can call this from each of the comboBoxes like this ...
private void comboBox1_Validating(object sender, CancelEventArgs e)
{
if (InvalidYear(sender))
e.Cancel = true;
}