I have an app where I have many buttons inside so to differentiate them, I create a class in which I put this: I have to say that my button is in a FlowLayoutPanel.
public static void SetButtonPos(Form f1,FlowLayoutPanel fk)
{
foreach (Button c in f1.Controls)
{
if(c.Name.Contains("BTN_Menu"))
{
c.Size= new Size(247, 45);
c.BackColor = ColorTranslator.FromHtml("#373737");
c.ForeColor = ColorTranslator.FromHtml("#FFFFFF");
c.FlatStyle = FlatStyle.Flat;
c.FlatAppearance.BorderSize = 0;
c.TextAlign = ContentAlignment.MiddleLeft;
c.TextImageRelation = TextImageRelation.ImageBeforeText;
c.Height = 45;
c.Width = fk.Width - 6;
}
}
}
But I got the error in the title, do you have any idea ?
Unable to cast object of type 'System.Windows.Forms.FlowLayoutPanel' to 'System.Windows.Forms.Button
Thank you.