You should be able to do this using the Controls collection, the following
code should be methods added to a base form that you derive from where you
need this functionality. The code is not compiled but more like pseudo
code...
-------------------------------------------------------------------
public void InsertBefore(Control targetCtrl, Control newControl) {
int index=-1;
if (targetCtrl != null && newControl != null) {
for(int i=0; i<this.Controls.Count; i++) {
if (targetCtrl.Equals(this.Controls)) {
index = i;
break;
}
}
if (index != -1) {
this.Controls.Insert(index, newControl);
}
}
}
public void InsertAfter(Control targetCtrl, Control newControl) {
int index=-1;
if (targetCtrl != null && newControl != null) {
for(int i=0; i<this.Controls.Count; i++) {
if (targetCtrl.Equals(this.Controls)) {
index = ++i; // Note the ++ indicates advance and then
capture the value!
break;
}
}
if (index != -1) {
this.Controls.Insert(index, newControl);
}
}
}