I have a code that should create user elements in a flowLayoutPanel. But, each element should only exist once.
This is my code:
flowLayoutPanelUser.Controls.Clear();
foreach (Data a in AllData)
{
if (a != null)
{
Button buttonHome = new Button();
buttonHome.Text = a.User;
buttonHome.Tag = a.User;
flowLayoutPanelUser.Controls.Add(buttonHome);
buttonHome.Click += new EventHandler(OpenUser_Click);
}
}
AllData is the input.
I am looking for something like this:
if (!toolStripMenuItem.DropDown.Items.Cast<ToolStripMenuItem>().Any(x => x.Text == a.Typ))
{
}
I had already been looking for a solution