Using this code to add a user control to a panel dynamically- the first one is always not aligned for some reason:
int li_numRoomCnt = 0;
for (int i = 0; i < 16; i++)
ucRoom lo_Room = new ucRoom();
lo_Room.SetRoomInfo((ushort)li_numRoomCnt, “Room ” + li_numRoomCnt);
lo_Room.Width = flp_Rooms.Width;
lo_Room.Location = new System.Drawing.Point(0, (lo_Room.Height * i) + 2);
The user control just contains a label, a text box and a button. See screenshot
Try to remove this.flp_Rooms.SuspendLayout(); It stops the layout engine, it should be used in pair with ResumeLayout() when needed. In this case it doesn’t look like it’s needed.
Please login first to submit.