有一个名为OnUserJoined
的事件,它会触发一个将控件添加到flowLayoutPanel
的进程。问题是控件没有出现,并且没有错误消息。为什么不工作?
public void Adduser(object sender, QMEventArgs e)
{
Console.WriteLine("Updating user list.");
MetroPanel up = new MetroPanel()
{
BackColor = Color.DodgerBlue,
CustomBackground = true,
Size = new System.Drawing.Size(1177, 76),
Style = MetroFramework.MetroColorStyle.Blue
};
MetroLabel uname = new MetroLabel()
{
Text = e.UserName,
AutoSize = true,
CustomBackground = true,
Dock = DockStyle.Top,
FontSize = MetroFramework.MetroLabelSize.Tall,
FontWeight = MetroFramework.MetroLabelWeight.Bold,
Location = new Point(0, 0),
Style = MetroFramework.MetroColorStyle.White,
UseStyleColors = true,
};
MetroLabel uip = new MetroLabel()
{
Text = e.UserIP,
AutoSize = true,
CustomBackground = true,
Dock = DockStyle.Top,
FontSize = MetroFramework.MetroLabelSize.Small,
FontWeight = MetroFramework.MetroLabelWeight.Regular,
Location = new Point(0, 25),
Style = MetroFramework.MetroColorStyle.White,
UseStyleColors = true,
};
up.Controls.Add(uip);
up.Controls.Add(uname);
flowLayoutPanel1.Controls.Add(up);
}