G
Guest
I want my method to be able to take any control and manipulate the
control....for example change the Location of the control. I get error
messages when I compile saying for example "Can't convert from ref Label to
ref Control" or "Can't convert from ref Panel to ref Control".
private void SetNewY(ref Control me, ArrayList controlsAboveMe) {
int bfr=7;
int ySize=0;
foreach (Control o in controlsAboveMe) {
ySize=o.Location.Y + o.Size.Height + bfr;
}
me.Location = new Point(me.Location.X, ySize);
}
private void ChangeControlLocations() {
ArrayList cAbove=new ArrayList();
cAbove.Add(calendar);
cAbove.Add(okBt);
SetNewY(ref myPanel, cAbove); //causes compile error
}
control....for example change the Location of the control. I get error
messages when I compile saying for example "Can't convert from ref Label to
ref Control" or "Can't convert from ref Panel to ref Control".
private void SetNewY(ref Control me, ArrayList controlsAboveMe) {
int bfr=7;
int ySize=0;
foreach (Control o in controlsAboveMe) {
ySize=o.Location.Y + o.Size.Height + bfr;
}
me.Location = new Point(me.Location.X, ySize);
}
private void ChangeControlLocations() {
ArrayList cAbove=new ArrayList();
cAbove.Add(calendar);
cAbove.Add(okBt);
SetNewY(ref myPanel, cAbove); //causes compile error
}