Skip to content

Dynamically adding user object to panel - first one not aligned #1286

Description

@itg-assistant

edmond girardi asked 2018-01-03 22:18:18 UTC

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++)
{
li_numRoomCnt++;

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);
this.flp_Rooms.Controls.Add(lo_Room);
this.flp_Rooms.SuspendLayout();
this.flp_Rooms.Controls.SetChildIndex(lo_Room, i);
}

The user control just contains a label, a text box and a button. See screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions