public void SetPosition() { int formWidth = mainForm.ClientRectangle.Width, formHeight = mainForm.ClientRectangle.Height - 10; int x = formWidth / IAP.MaxCols * (col - 1), y = 0; foreach (var iap in IAP.IAPs.Values.Where(o => (o.col == col) && (o.row < row))) { y += ((IAP)iap).CalculateHeight() + 5; } foreach (var caption in Captions.Where(o => (o.col == col) && (o.row < row))) { y += ((Caption)caption).Height; } this.Width = formWidth / IAP.MaxCols; this.captionLabel.Width = this.Width; this.Location = new Point(x, y); }